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
10 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
10 years ago

The == Operator

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

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

1local val1 = 4
2local val2 = 2 * 2
3 
4if val1 == val2 then
5    print('Equivalent!')
6end

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.

1local val1 = 4
2local val2 = 1
3 
4if val1 ~= val2 then
5    print('Not Equivalent!')
6end

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

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

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

Example:

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

Answer this question