Operators
Operators are little symbols that do work.
They let you calculate, compare, and combine values.
Go feels familiar if you know other C-style languages.
One difference: Go has no ternary ?: operator.
Arithmetic operators
+ adds. - subtracts. * multiplies. / divides. % is the remainder.
With whole numbers, / drops the fraction. 10 / 3 is 3.
++ and --
++ adds one. -- subtracts one.
They only work as statements, not inside bigger expressions.
Comparison operators
Comparisons give back bool: true or false.
Use == != < > <= >= to ask questions about values.
Numbers do not turn into true or false by themselves.
Logical operators
&& means and. Both sides must be true.
|| means or. One true side is enough.
! means not. It flips true to false and false to true.
Assignment operators
You can mix math with assignment.
+= -= *= /= and %= update the same labeled box in place.
Next: use these comparisons inside if / else to make decisions.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.