box-o-sand/RubyFun/cookbook/007/01.rb
Dan Buch 0a9428093c Add 'RubyFun/' from commit 'b01c6826131196ba58b5288a3182f2526c89c249'
git-subtree-dir: RubyFun
git-subtree-mainline: a04a502787
git-subtree-split: b01c682613
2013-01-09 23:50:14 -05:00

29 lines
487 B
Ruby

# WRONG
# aBlock = { |x| puts x }
# RIGHT
aBlock = lambda { |x| puts x }
aBlock.call "Hello World!"
def my_lambda(&aBlock)
aBlock
end
b = my_lambda { puts "Hello World My Way!" }
b.call
aBlock = Proc.new { |x| puts x }
aBlock = proc { |x| puts x }
aBlock = lambda { |x| puts x }
add_lambda = lambda { |x,y| x + y }
# add_lambda.call(4)
# add_lambda.call(4,5,6)
puts add_lambda.call(4,2)
add_procnew = Proc.new { |x,y| x + y }
# add_procnew.call(4)
puts add_procnew.call(4,5,6)