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

What does == and ~= mean?

Asked by
iNicklas 215 Moderation Voter
9 years ago

I don't really get it :P

2 answers

Log in to vote
6
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

The == Operator

The == operator is the operator for comparing equivalent values.

val1 == val2 - if val1 is equivalent to val2.

local val1 = 4
local val2 = 2 * 2

if val1 == val2 then
    print('Equivalent!')
end

The above code would print Equivalent! because val1 is equivalent to val2.


The ~= Operator

The ~= operator is the comparing non-equivalent values! The exact opposite of ==.

val1 ~= val2 - if val1 is not equivalent to val2.

local val1 = 4
local val2 = 1

if val1 ~= val2 then
    print('Not Equivalent!')
end

The above code would print Not Equivalent! because val1 is not equivalent to val2.

1
and "=" will change the value of something. alphawolvess 1784 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

Both == and ~= are used in if or repeat - until functions. == means 'is equal to', and ~= means 'is NOT equal to'.

Example:

if Value == true then
    --Code
    elseif Value ~= true then
    --Other code
end
0
Hmm, I see. Thanks for the fast reply bud :D iNicklas 215 — 9y
0
'if' isn't a function, it's a statement. 'repeat - until' isn't a function, it's a loop. Goulstem 8144 — 9y

Answer this question