It's possible to store code blocks within variables, using the lambda method : lambda « Method « Ruby






It's possible to store code blocks within variables, using the lambda method


print_parameter_to_screen = lambda { |x| puts x }
print_parameter_to_screen.call(100)

 








Related examples in the same category

1.Use lambda to create a block
2.Use lambda to create a list of function
3.Invoking Blocks
4.return a lambda function
5.Provide different number of parameters for lambda