I've searched for an answer here and elsewhere online, but all topics deal with either iterating a table, metatables, or times when _,var1 = do_some_stuff()
which are not the case here.
This is just a non-realistic function, but containing examples of what I mean:
function do_some_stuff(data)
_ = some_function(data)
some_other_code
_ = some_other_function(data)
end
Wouldn't this be considered the same as simply entering:
function do_some_stuff(data)
some_function(data)
some_other_code
some_other_function(data)
end
I know that if I create a basic Lua program like this both versions run the same:
function hello(state)
print("World")
end
function ugh(state)
_ = hello(state) -- and w/ hello(state) only
end
ugh(state)
I just would like to know if there can be a time where this _ = some_function()
is necessary?
There is no benefit to _ = do_some_stuff()
, rather using do_some_stuff()
is fine and more accepted. The underscore provides no benefit when used in this way.
Thanks Etan Reisner and Mud for the help and clarification.