Sha256: 22ef95d03a4fcbda2bcec60ebe7cded57f26340a1bb95731abf3f23b9fe63aa8

Contents?: true

Size: 440 Bytes

Versions: 2

Compression:

Stored size: 440 Bytes

Contents

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. Procs can be used
like variables themselves and passed to functions
as arguments. In order to execute the Proc, the
'call' method should be used.

Example:
square = Proc.new {|n| n**2}

def exec_proc(block, num)
  block.call(num)
end

exec_proc(square), 6)    #=> 36

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubytutor-0.1.1 lib/descriptions/Proc.txt
rubytutor-0.1.0 lib/descriptions/Proc.txt