Home Segments Index Top Previous Next

166: Sidetrip

It is possible to use an and: message instead of an ifTrue: message by exploiting the property that the argument block in an and: expression is evaluated only if the receiver is true.

Note, however, that most programmers object to the use of and: and or: messages to only allow or prevent evaluation. They argue that, when an and: or or: message is included in an expression anyone—other than the original programmer—naturally expects the value produced by the expression to be used. If the value is not used, the person who looks at the program may wonder whether the original programmer left out a portion of a method definition unintentionally.