Home Segments Index Top Previous Next

66: Mainline

As Smalltalk evaluates the expression 6 + 3 * 2, the message + 3 is sent to 6, which answers 9. Then, the message * 2 is sent to 9, which answers 18. Thus, Smalltalk takes 6 + 3 * 2 to be equivalent to (6 + 3) * 2, rather than to 6 +(3 * 2), even though the precedence of multiplication is higher than that of multiplication in ordinary arithmetic:

6 + 3 * 2       <-- Equivalent to (6 + 3) * 2, rather than 6 + (3 * 2)