- A Boolean expression is an expression that evaluates to
true
or
false
.
- A block is a sequence of statements delimited by brackets. The value
produced when a block is evaluated is the value produced by the final
statement in the block.
- If you want to evaluate an expression only when a Boolean expression
evaluates to
true
, then use an ifTrue:
message:
Boolean expression ifTrue: if-true block
- If you want to evaluate an expression only when another expression
evaluates to
false
, then use an ifFalse:
message:
Boolean expression ifFalse: if-false block
- If you want to evaluate one expression when a predicate expression
evaluates to
true
, and a second expression, when the predicate
expression evaluates to false
, then use an ifTrue:ifFalse:
or an ifFalse:ifTrue:
message:
Boolean expression
ifTrue: if-true block
ifFalse: if-false block
Boolean expression
ifFalse: if-false block
ifTrue: if-true block
- If you want to a method to answer with a value produced inside a block,
then include an answer expression in that block.