Lua中有一个pass语句,就像在python中一样

Pra*_*aur 9 lua

就像在python中一样,我们有pass语句.

def calcu():
    pass

在Lua有这样的声明吗?我想要做

if connect then 
    pass

Yu *_*Hao 10

pass在Python中什么都不做.在Lua中,你可以把它留空:

if connect then end
Run Code Online (Sandbox Code Playgroud)

如果需要占位符,请使用空块

if connect then do end end
Run Code Online (Sandbox Code Playgroud)

或者如果在Lua 5.2中,使用分号:

if connect then ; end
Run Code Online (Sandbox Code Playgroud)

  • `如果连接的话; 在Lua 5.2之前,end`无效 (6认同)