This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
at:tutorial:objects [2007/08/04 11:02] tvcutsem added |
at:tutorial:objects [2013/05/17 20:23] (current) tvcutsem updated |
||
---|---|---|---|
Line 174: | Line 174: | ||
}; | }; | ||
def each: clo { | def each: clo { | ||
- | 1.to: elements.length | + | 1.to: elements.length do: { |i| |
clo(elements[i]); | clo(elements[i]); | ||
}; | }; | ||
Line 184: | Line 184: | ||
< | < | ||
- | > Array.add(1).add(2).add(3) | + | Array.add(1).add(2).add(3) |
- | >> < | + | def c := Array.collect: |
- | > def c := Array.collect: | + | c.each: { |v| system.print(v)} |
- | >> < | + | |
- | > c.each: { |v| system.print(v)} | + | |
- | 234 | + | |
- | >>nil | + | |
</ | </ | ||
Line 233: | Line 229: | ||
> makeBankAccount(100).balance; | > makeBankAccount(100).balance; | ||
>> | >> | ||
- | <object:5068254> | + | <obj:{super, |
</ | </ | ||