The Six Comparisons
You rarely type True by hand. Booleans usually arrive as the answer to a comparison. Six operators produce them:
> greater than · < less than
>= greater or equal · <= less or equal
== equal to · != not equal to
✦ The one that bites everybody
One equals sign (=) ASSIGNS a value. Two equals signs (==) COMPARE two values and give back a Boolean. age = 18 stores 18. age == 18 asks a question. Mixing them up is the single most common beginner bug in every language.
Mark this lesson complete
Signed in, your progress follows you to every device.