47

What does the ~= operator mean in Lua?

For example, in the following code:

if x ~= params then
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Alejandro Simkievich
  • 3,512
  • 4
  • 33
  • 49

4 Answers4

65

the ~= is not equals

It is the equivalent in other languages of !=

caulitomaz
  • 2,141
  • 14
  • 20
15

The operator ~= is exactly the negation of equality (==).

See docs.

pushkin
  • 9,575
  • 15
  • 51
  • 95
  • 1
    thanks a lot for pointing to the docs pushkin - for some reason googling ~= did not work for me. But now that I see the code, it makes a lot of sense. – Alejandro Simkievich Jan 11 '16 at 02:17
7

During compilation it gets translated to not a == b.

Creator
  • 151
  • 1
  • 9
2

~= in Lua, is just like doing != in other languages like C#.

TERIHAX
  • 237
  • 2
  • 14