2.5 Arithmetic Operator Style Guide
5️⃣

2.5 Arithmetic Operator Style Guide

2.5 Arithmetic Operator Style Guide

When using operators, there are certain things that would make your code much easier to read. Note: Bad style isn’t wrong, but if you're working or showing your code to someone else, trying to make it easily understandable to that person would be great.
Good style = Easily readable code.
a += 1; a = 5 - 1; a++;
Bad style = A programmer wanting to burn all of your existence in the project (Metaphorically).
a+=1; a=5 -1; a ++;
 
It may be tempting to cram a lot of operators into one line (“I personally love one liners.” - Matthew (The guy making this)). However, it may make your code a bit confusing.
a += b++ * --a % 50;
It may be a little hard for another programmer to know what the heck you wrote. So, it would be much better to break the code into separate lines.
a += b; --a; a %= 50; b--;

Previous Section

4️⃣
2.4 Points To Remember About Variables
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.