Question: In Section 14.4.1 we claimed that nested blocks in Ruby were part of the named scope in which they appear. Verify this claim by running
In Section 14.4.1 we claimed that nested blocks in Ruby were part of the named scope in which they appear. Verify this claim by running the following Ruby script and explaining its output:

Now comment out the second line (y = 2) and run the script again. Explain what happens. Restate our claim about scoping more carefully and precisely.
def foo(x) y = 2 bar = proc { print x, " " y = 3 } bar.call() print y, " " end foo (3)
Step by Step Solution
3.49 Rating (166 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
