3 ms·
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
by extension 17y ago
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.