in recent versions of Ruby, many methods in Enumerable return an Enumerator when they are called without a block:
Enumerable
Enumerator
[1,2,3,4].map #=>
use Enumerator#new:
class Array def double(&block) Enumerator.new do |y| each do |x| y.yield x*2 end end.each(&block) end end