Loops/Foreach: Difference between revisions
Content added Content deleted
Line 2,384: | Line 2,384: | ||
(and because Aikido mentions it: of course this works for any kind of collection (and even things which simply implement a <tt>do:</tt> method to iterate on something) |
(and because Aikido mentions it: of course this works for any kind of collection (and even things which simply implement a <tt>do:</tt> method to iterate on something) |
||
<lang smalltalk>(1 to:6 by:2) do:# |
<lang smalltalk>(1 to:6 by:2) do:#displayNl. |
||
'hello' do:# |
'hello' do:#displayNl. |
||
(Integer primesUpTo:100) do:# |
(Integer primesUpTo:100) do:#displayNl. |
||
'/' asFilename directoryContents do:# |
'/' asFilename directoryContents do:#displayNl. |
||
((Smalltalk allClasses collect:#name) asSortedCollection to:2) do:# |
((Smalltalk allClasses collect:#name) asSortedCollection to:2) do:#displayNl. |
||
funnyClassLessObject := Plug new |
funnyClassLessObject := Plug new |
||
Line 2,395: | Line 2,395: | ||
arg value:'look ma'. |
arg value:'look ma'. |
||
arg value:'no classes needed']. |
arg value:'no classes needed']. |
||
funnyClassLessObject do:# |
funnyClassLessObject do:#displayNl. |
||
etc.</lang> |
etc.</lang> |
||
{{out}} |
{{out}} |