# 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

* Object

### Class Method

Proc.newProc.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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enls.gitbook.io/rgss-reference-manual/standard-library/built-in-classes/object/proc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
