Loops/Foreach: Difference between revisions
Content deleted Content added
Line 2,378: | Line 2,378: | ||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
<lang smalltalk>aCollection do: [ :element | element displayNl ].</lang> |
<lang smalltalk>aCollection do: [ :element | element displayNl ].</lang> |
||
Provided that the objects in the collection understand the <code>displayNl</code> method (which can be added, if missing). |
|||
Most modern Smalltalks allow for a selector symbol to be sent a <tt>value:</tt> message; which allows for the very compact: |
Most modern Smalltalks allow for a selector symbol to be sent a <tt>value:</tt> message; which allows for the very compact: |
||
<lang smalltalk>aCollection do:#displayNl.</lang> |
<lang smalltalk>aCollection do:#displayNl.</lang> |