russellallen/self

Is "^" an operator or not?

Opened this issue · 1 comments

dram commented

In handbook 3.4.5. Operators, ^ is said to be reserved and is not an operator, but in adjacent Examples ^ is included, so is ^ an operator or not?

I think there's a bit of imprecision with the use of the word 'operator'.

^ is a reserved character and can't be used as part of a method name.

However it is used to indicate an immediate non-local return from within a block, e.g.

assertPositive: x = ( x > 0 ifTrue: [ ^ ’ok’ ]. error: ’non-positive x’ )

If x > 0 then this will return 'ok' and the error: message won't be sent.