Proc objects are blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables.

def gen_times(factor)
  return {|n| n*factor }

times3 = gen_times(3)
times5 = gen_times(5)               #=> 36                #=> 25   #=> 60
Show files where this class is defined (1 file)
Register or log in to add new notes.