Category:Smalltalk: Difference between revisions

m
Line 380:
As mentioned above, these are defined as messages and their implementation is found in the corresponding receiver classes. The following is only a tiny subset - there are virtually hundreds of uses of blocks for control structures in the system.
Typical are:
<lang smalltalk>boolean ifTrue: [ block providing value if boolean is true ]
boolean ifTrue: [ block providing value if boolean is true ]
 
boolean ifFalse: [ block providing value if boolean is false ]
Line 389 ⟶ 388:
[ block for condition ] whileTrue: [ block to be looped over ]
 
n timesRepeat: [ block to be looped over ]
 
start to: stop do: [:i | block to be looped over with index ]
 
collection do: [:el | block to be evaluated for each element ]
 
</lang>
collection reverseDo: [:el | block to be evaluated for each element ]</lang>
 
=== Exception Handling ===
Anonymous user