Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNOUR A ALGHAMDI
Courses Plus Student 5,607 Pointswhy 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 ?
1 Answer
Martin Wildfeuer
Courses Plus Student 11,071 PointsOperator 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.
NOUR A ALGHAMDI
Courses Plus Student 5,607 PointsNOUR A ALGHAMDI
Courses Plus Student 5,607 Pointsyes , thank you :)