fun with splats


M

Martin DeMello

class A
include Enumerable

def each
yield :foo
yield :bar
yield :baz
end
end

a = A.new
b = *a #=> [:foo, :bar, :baz]

(Enumerable defines a to_a, and * works with anything that has to_a
defined).

martin
 
Ad

Advertisements


Top