Proc

Proc is a procedure object in which both a block and its context (local variable scope and stack frame) have been encapsulated as an object. Proc can be used like an unnamed function, except that it does not have its own local variable scope.

We can see that Proc retains a local variable scope, however, by observing that the variable var can be referenced, as in the example below:

var = 1
$foo = Proc.new { var }
var = 2

def foo
  $foo.call
end

p foo       # => 2

Superclass

Class Method

Proc.new
Proc.new { ... }

Encapsulates a block, along with its context, into an object and returns it.

If no block is specified, but the method that called Proc.new contains a block, that block will be created as a Proc object and returned.

Method

call(arg ... )

Executes a procedure object and returns the result. Arguments are assigned to block parameters as is (according to the rules of multiple assignation).

Converted from CHM to HTML with chm2web Pro 2.85 (unicode)