News for hackers. Stuff that matters.
Re:Ruby Best Practices (full book available for download) by richcollins on Thursday March 18, 2010 @01:03PM (#1201798)
Setters are composable and you can modify their behavior. Hash literals ... not so much.

It would seem you only see the surface beauty of things. [redacted -- good point]

Re:Ruby Best Practices (full book available for download) by jamesbritt on Thursday March 18, 2010 @01:13PM (#1201835)
"It would seem you only see the surface beauty of things."

Is that how you defend an API? Insult the user?

Holy shit that's stupid.

Re:Ruby Best Practices (full book available for download) by extension on Monday April 19, 2010 @09:38AM (#1276652)
How about adding this to the Point class?

  def to_hash
    {:x => @x, :y => @y}
  end
  
  def to_ary
    [@x,@y]
  end

  def [] i
    case i
    when 0,:x
      @x
    when 1,:y
      @y
    end
  end
Should work if the receiving method interprets the arguments properly.