Jump to content

Category:Smalltalk: Difference between revisions

Line 501:
 
This makes it possible to pass a block to eg. collections to enumerate elements up-to and until some condition is met. For example, if we need a helper method, which returns the first element from a dataset which meets some condition, we can write:
<lang smalltalk>findSomeElementWhichMeetsCondition:conditionBlock thenDo:actionBlock ifNone:failBlock
<lang smalltalk>
findSomeElementWhichMeetsCondition:conditionBlock thenDo:actionBlock ifNone:failBlock
dataSet do:[:eachElement |
(conditionBlock value:eachElement) ifTrue:[
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.