_ happens only in Lua

Do you have functions that return more than one result? Well, not that I expect the function to return the same value, but more than one result as in x,y = getPosition()

In the case of an iPair loop, there might be the same

for k,v in iPairs(table) do

What if you do not want to assign some value to a variable, simple, k and v are getting assigned values, disregard the k if you are not interested. What if you did not want to use any variable at all?

Here comes the Undertaker, whoops, the Underscore, this is a special variable in Lua that can be used as a normal variable, so it is perfectly fine to use

 _ = "Hello World"
 print( _ )

because you would not assign or use this in your code, you can use this for all dummy values that you want to ignore.

Unfortunately, this code *does not* work
 ^_^ = "Hello Kitty"
 print( ^_^ )

it would be cool though




Popular Posts