Blocks, Procs, and Lambdas
Learn the similarities and differences between a _block_, _proc_, and _lambda_ as well as the various circumstances in which each one can be
StartKey Concepts
Review core concepts you need to learn to master this subject
Ruby .call Method
Ruby .call Method
proc_test = Proc.new { puts "I am the proc method!" }
lambda_test = lambda { puts "I am the lambda method!"}
proc_test.call # => I am the proc method!
lambda_test.call # => I am the lambda method!
#The following code would result in "I am the proc method!" and "I am the lambda method!" printed to the console respectively, once the proc, proc_test, and the lambda, lambda_test, are called.
In Ruby, a proc and a lambda can be called directly using the .call
method.
Blocks, Procs, and Lambdas
Lesson 1 of 1