RosettaCodeData/Task/Higher-order-functions/Ruby/higher-order-functions-1.rb
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

7 lines
81 B
Ruby

succ = proc{|x| x+1}
def to2(&f)
f[2]
end
to2(&succ) #=> 3
to2{|x| x+1} #=> 3