05/10 2011

Ruby doesn’t support that particular technique because it’s object-oriented more than it’s functional:

 
[1, 2, 3].each{|n| puts n}

However, in 1.9.2, you can snatch a Method from an object using the Object#method method:

 
method(:print) #=> #<Method: Object(Kernel)#print>
5.method(:+).call(8) #=> 13

And you can even turn a Method into a Proc or syntactic block:

 
"big balls".method(:split).to_proc #=> #<Proc:0x00000100d98ec8 (lambda)>
[1, 2, 3].each(&method(:puts))