我在这里和其他在线位置搜索了答案,但是所有主题都涉及迭代表,元表或_,var1 = do_some_stuff()
此处不是这种情况的时间。
这只是一个非现实的功能,但包含了我的意思的示例:
function do_some_stuff(data)
_ = some_function(data)
some_other_code
_ = some_other_function(data)
end
难道这与简单地输入不一样:
function do_some_stuff(data)
some_function(data)
some_other_code
some_other_function(data)
end
我知道,如果我创建像这样的基本Lua程序,则这两个版本将以相同的方式运行:
function hello(state)
print("World")
end
function ugh(state)
_ = hello(state) -- and w/ hello(state) only
end
ugh(state)
我只是想知道是否有_ = some_function()
必要这样做?
不会带来任何好处_ = do_some_stuff()
,而是可以使用do_some_stuff()
且被人们接受。当以这种方式使用时,下划线没有任何好处。
感谢Etan Reisner和Mud的帮助和澄清。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句