[Newbies] Does +, -, *, / have more precedence over power?
Yoshiki Ohshima
Yoshiki.Ohshima at acm.org
Sat Nov 11 23:42:23 UTC 2017
On Sat, Nov 11, 2017 at 2:12 PM, RedTigerFish <chihuyu at gmail.com> wrote:
>
> Is it because that +, -, *, / have more precedence over power ?
>
Others already gave good answers but I want to point out just one thing:
the precedence rule is purely syntactical (i.e. computer decides it from
only the text). What those methods actually do is irrelevant.
For example, you can define a method called **, such as:
--------------
** aNumber
^ self raisedTo: aNumber.
-------------
and then, you can write:
2 ** 3 + 1
to get 9.
--
-- Yoshiki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20171111/c0c4d525/attachment.html>
More information about the Beginners
mailing list