To repeat a given number of times an action
4 timesRepeat: [ self doSomething ]
1 to: 100 do:
[ :i | ... i ... ]
to:do:
is a method defined on Number
The block is executed with the temporary i
taking values from 1 to 100
1 to: 100 do:
[ :i | Transcript show: i ; space ]
0 to: 100 by: 3 do: [ :i | ... i ... ]
to:by:do:
is also a method defined on Number
The block is executed with i taking values from 1 to 100 by step of 3
1 to: 100 by: 3 do:
[ :i | Transcript show: i ; space ]
do:
(iterate)collect:
(iterate and collect results)select:
(select matching elements)reject:
(reject matching elements)detect:
(get first element matching)detect:ifNone:
(get first element matching or a default value)includes:
(test inclusion) aCol do: [ :each | ... ]
The block is executed with each
taking as value all the elements of aCol
#(15 10 19 68) do:
[:i | Transcript show: i ; cr ]
[ ... ] whileTrue: [ ... ]
Executes the argument, aBlock
, as long as the value of the receiver is true
Color >> atLeastAsLuminentAs: aFloat
| revisedColor |
revisedColor := self.
[ revisedColor luminance < aFloat ]
whileTrue: [ revisedColor := revisedColor slightlyLighter ].
^ revisedColor
Executes the receiver, as long as its value is true
[ ... ] whileTrue
Equivalent with whileFalse
and whileFalse:
/