Anonymous user
Loops/Foreach: Difference between revisions
→{{header|Smalltalk}}
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)
<lang smalltalk>(1 to:6 by:2) do:#
'hello' do:#
(Integer primesUpTo:100) do:#
'/' asFilename directoryContents do:#
((Smalltalk allClasses collect:#name) asSortedCollection to:2) do:#
funnyClassLessObject := Plug new
Line 2,395:
arg value:'look ma'.
arg value:'no classes needed'].
funnyClassLessObject do:#
etc.</lang>
{{out}}
|