I want to ask when do I use the double equal signs eg. "==" and WHY people use it because I have seen it being used so many times and I do not know what it means.
What are double equal signs for?
3 answers
== -- means, equal to.
>= -- means, whatever is greater than or equal to.
<= -- means, whatever is less than or equal to.
~= --means, is not equal to nil.
-- As a example, just one so you can get the idea.
if 1 == 1 then
print("See")
end
if this helped +1, if this answered your query check mark :)
== means is equal to
Example:
local NumVar = 4
if NumVar == 2+2 then
print("NumVar = 4! :D")
end
= means equal just like in math
Example:
Local Hello = "Hello is the index"
If you were to say..
local NumVar = 4
if NumVar = 2+2 then
print("NumVar = 4! :D")
end
This would error because it would be setting NumVar to 2+2 in an IF statement which would error
If you were to say..
Local Hello == "Hello is the index"
That would error because that would saying Hello equals that which it doesnt plus it isnt wrapped inside of a statement which would error regardless if it does or doesnt.
Hope you learned the difference c;
== is an operator in the same sense that + or - or * is an operator.
It refers to "equal to" in the sense of comparing two values for equality, that is, a == b is true iff a and b are the same.
In addition to ==, there are the operators > (larger than), < (less than), >= (larger than or equal to), <= (less than or equal to), and ~= (not equal to).
It is completely unrelated to the single equals, =.
= is not an operator. It refers to assignment and forms a statement.
If the value of something is being set, then = is used. If the value of something is being compared, then == would be used. These two symbols are completely unrelated except for their common ground in mathematical notation.
I posted this answer as well because I felt the other answers did not properly describe the meaning of == in a way exact enough that it does not spawn more questions
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Hello tochi :)