Use lambda to create a block : lambda « Method « Ruby






Use lambda to create a block

#!/usr/bin/env ruby

prc = lambda { |name| puts "Hello, " + name }

prc. call "myValue!"

 








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 list of function
3.Invoking Blocks
4.return a lambda function
5.Provide different number of parameters for lambda