( )
just changes the priority of an execution but the program is executed[ ]
blocks program execution: the program is NOT executed
Use [ expressions ]
when:
expressions
may not be executed at all (if, and, ...)expressions
may be executed multiple times (while, ...)n timesRepeat: [ self doSomething ]
timesRepeat:
executes a number of times its argument, therefore the argument is a block
x isNil ifTrue: [ self doSomething ]
ifTrue:
may execute or not its argument, therefore the argument is a block
[ self start ] whileTrue: [ self doSomething ]
whileTrue:
may execute both its receiver and argument multiple times, therefore they are both a block
1 to: n do: ... self doSomething ...
x ifEmpty: ... self doSomething ...
( )
is about changing the order of a computation[ ]
is freezing the computation and controlling it/