Errata

Ruby Pocket Reference

Errata for Ruby Pocket Reference

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 24
3rd paragraph

The example is describing possible scoping issues that may occur. I've noticed a similar quirk in python, so I tried out the author's example, but it doesn't work as stated.

```
j = 7

(1..4).to_a.each { | j | } # j now equals 4

```

The initializing of the local variable within the each block does not override the variable of the same name in the containing scope.

In python this is the case, for example:

```
j = 7

for j in range(5):
print("hi")

""" j will equal 4 here """

```

Anonymous  Jul 04, 2020