Calls block once for each element of an array, passing that element as a parameter
- by Puru puru rin..
Hello,
I have some difficulties for using Ruby block, passing in a method.
As in the following case, I would like to display each element of @array, from Box instance (using .each method):
class Box
def initialize
@array = [:foo, :bar]
end
def each(&block)
# well, hm..
end
end
a = Box.new
a.each { |element| puts element }
Thanks for any help.