## Learn how to use the relational operators.

### by ThePotatoCamera ## Math logic is the same in programming?

In the lessons or in other tutorials maybe you saw something like this:

``````local a = 2
if (a == 2) then print('a is 2')
end
``````

As you can see, in programming using "=" means "define a variable", while "==" in the

condition means that the value must be the same. Actually, we can use "===" to define this as a "strict"

equivalence. In other words, if the value must be the same as requested always. However, the " ==" is more used.

## But I want something different...

However, we can use a condition in which the value must be different from the one at the variable.

``````a = 2
if (a ~= 2) then print('a is not 2')

else print ('a is 2')

end
``````

As you can see, a is 2, so the condition that a value must not be 2 is not completed, then

we print "a is 2". We can ask a different value just typing "~=", where "~" means "different". This is useful to know, since asking for a different value is often used.

## I want more.... or maybe less...

So, let's say you want to create a first person shooter, something basic is the ammo.

Let's create an easy example:

``````bullets = 100
if (bullets > 0) then print("pew pew"), bullets - 1
else if (bullets == 0) then print ("No ammo")
end
``````

In this very basic example, we can see that while bullets are higher than 0, we'll shoot.

But if we have 0 bullets, then we have no ammo. We can ask for higher or lower values with

">" or "<", just like maths. We can also mix them with "=": ">=" or "<=", so we also ask for higher/lower values AND the

same value.

## Tip of the day!

Think that these operators are like a switch, while the condition is not met, they will

output "false", but when the condition is completed, the output turns "true".