tags:

views:

77

answers:

1
a > b
ifTrue:[ 'greater' ]
ifFalse:[ 'less or equal' ]

My understanding is that Boolean a > b receives the message ifTrue:[ 'greater' ], and then ifFalse:[ 'less or equal' ] complying to the generalization:

objectInstance selector; selector2

But there a semicolon is needed to specify that the receiver of selector2 is not (objectInstance selector) but objectInstance. Is not the same with the above conditional execution?

+13  A: 

The selector of the method is Boolean>>ifTrue:ifFalse:, which means it is one method with two parameters, not two methods with one parameter.

Ergo, to invoke the method, you send it the message ifTrue:ifFalse: with two block arguments.

Note that for convenience reasons, there are also methods Boolean>>ifFalse:ifTrue:, Boolean>>ifTrue: and Boolean>>ifFalse:.

Jörg W Mittag