Mega Code Archive

 
Categories / Ruby / Method
 

Convert a block into an object

# This object is called a proc (procedure).  # procs preserve their execution environment and pack it along with them.  # The lambda method is one way to create a proc object.  prc = lambda { |name| puts "Hello, " + name } prc.call "Matz!" # => Hello, Matz!