Invoking Blocks : lambda « Method « Ruby






Invoking Blocks


block = lambda { |x| puts x }          # RIGHT

block.call "Hello World!"
# Hello World!

 








Related examples in the same category

1.It's possible to store code blocks within variables, using the lambda method
2.Use lambda to create a block
3.Use lambda to create a list of function
4.return a lambda function
5.Provide different number of parameters for lambda