# Booleans

Let me preface this by saying that there's a lot more to booleans than I'll be covering here. This is, after all, meant to be a SIMPLE tutorial.

With that out of the way, let's ask: What is a boolean? Well, that's simple. A boolean is a piece of data whose value is either "true" or "false".

When you use an if statement, the condition in it is interpreted as a boolean. If the condition is a variable whose type is a boolean, what happens then is intuitive and simple. If the value is true, the statement activates. If it is false, it does not. But let's say that you gave it a variable that isn't a boolean. If the variable is nil, then it evaluates as false. But if it is any other data type, it evaluates as true. This acts as a simple way to check if a variable exists, among other things.

But let's say you want to compare to variables for a condition. For example, check if one variable has the same value as another. Well, you can do that! Let's look to the right for our examples.

For our examples, we see various comparison operators. == means "equal to", and will return true if both values are the same, false otherwise. > means "greater than", and will return true if the first value is greater than the second, false otherwise. < means "less than" and will do the opposite- return true if the first value is less than the second one, false otherwise. >= means "greater than or equal to", and, as you likely guessed, returns true if both values are the same or the first value is greater than the second one, and false otherwise. <= means "less than or equal to", and, of course, returns true if both values are the same, or the first value is less than the second, and false otherwise. ~= means "not equal to", and returns true if the values are not the same, false if they are. "Not" is a special operator in this, and causes the result of the boolean expression or variable to be inverted. In other words, if you put it before a boolean variable or comparison that would return true, then it returns false instead, and vice versa.

``` foo = "test" bar = "test" foo == bar --evaluates as true not foo == bar --evaluates as false foo ~= bar --evaluates as false num1 = 25 num2 = 30 num1 > num2 --evaluates as false num1 < num2 --evaluates as true num1 ~= num2 --evaluates as true num3 = 55 num4 = 55 num3 >= num4 --evaluates as true num3 <= num4 --evaluates as true ```