... | ... | @@ -21,8 +21,8 @@ It was pointed out that this is inconsistent with the array indexing conventions |
|
|
As such, when using to:do: to iterate over or to initialize a table, one had to use the following pattern:
|
|
|
|
|
|
```
|
|
|
def table[{ nil }
|
|
|
1.to: table.length + 1 do: { | i | table[i](5]) := i * i }
|
|
|
def table[5] { nil };
|
|
|
1.to: table.length + 1 do: { | i | table[i] := i * i }
|
|
|
```
|
|
|
|
|
|
Notice the `+ 1` increment on the upper bound.
|
... | ... | @@ -38,8 +38,8 @@ will print the numbers `1,2,3,4,5` |
|
|
and this range now corresponds one-to-one to our array indexing:
|
|
|
|
|
|
```
|
|
|
def table[{ nil }
|
|
|
1.to: table.length do: { | i | table[i](5]) := i * i }
|
|
|
def table[5]{ nil };
|
|
|
1.to: table.length do: { | i | table[i] := i * i }
|
|
|
```
|
|
|
|
|
|
Another change is that to:do: no longer automatically "counts down" when the start is bigger than the end, i.e. currently:
|
... | ... | @@ -58,7 +58,7 @@ This code now instead never execute its block. There is a new `downTo:do:` metho |
|
|
|
|
|
will print the numbers `5,4,3,2,1`
|
|
|
|
|
|
Notice that the `downTo:do:` method's lower bound is inclusive, to match the behavior of the `to:do:` method.
|
|
|
Notice that the `downTo:do:` method's lower bound is **inclusive**, to match the behavior of the `to:do:` method.
|
|
|
|
|
|
All of the above changes also apply to `to:step:do:` and the new `downTo:step:do:` method.
|
|
|
|
... | ... | |