Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What are double equal signs for?

Asked by 10 years ago

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.

3 answers

Log in to vote
4
Answered by
HexC3D 830 Moderation Voter
10 years ago
== --  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 :)

Ad
Log in to vote
0
Answered by 10 years ago

== 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;

0
Hello tochi :) HexC3D 830 — 10y
Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

== 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

Answer this question