Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
why the binary operations have to be organised ?
i mean why the programming language does not calculate the binary operations as what we write ? why it has to start with multiplication and end with addition or subtraction ?
Martin WildfeuerCourses Plus Student 11,071 Points
Operator precedence or Order of Operations is a common mathematical concept that applies internationally. Swift and almost all other programming languages adhere to it. You can read more about it here.
1 + 2 * 3 = ?
If you hand someone a note with this task, she or he will come to the result 7, as they learned in school "multiplication and division first, then addition and subtraction".
So, in a nutshell, Swift just follows rules that have always applied. Everything else would be much more confusing, so we better stick to this standard.