doing 7.1
This commit is contained in:
parent
de8cf13289
commit
584e1eceb2
28
cookbook/007/01.rb
Normal file
28
cookbook/007/01.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# 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)
|
Loading…
Reference in New Issue
Block a user