Is it standard across all languages for the following to yield the value 3?
Print(6 - 2 - 1)
In other words, are there any languages that will evaluate ” 2 – 1 ” before ” 6 – 2 “?
I’d like to make this assumption so that I can quit instinctively inserting parentheses ((6 – 2) – 1). It leave me at risk of LISP nightmares.
Thanks
Generally when multiple operations have the same precedence they are evaluated from left to right similar to arithmetic. I wouldn’t want to say ALL languages because I haven’t done a survey of all but it makes sense that it should be so. I would still read the docs carefully for whatever new language I was going to try.