Ruby - Enumerable and Collection Processing
What will be the output of this Ruby code?
class MyCollection
include Enumerable
def initialize(items)
@items = items
end
def each
@items.each { |item| yield item }
end
end
col = MyCollection.new([1, 2, 3])
p col.map { |x| x * 2 }