Search code examples
pythonlua

Statement that does nothing in Lua, like Python's "pass"


I've recently started learning Lua. The only other programming language I have some experience in is Python. In Python there is the "pass" function that does nothing. I was wondering what the equivalent (if any) of this would be in Lua.


Solution

  • In Python, pass is an important placeholder for incomplete code. It must exist because Python doesn't allow empty code blocks. Stuff like if statements, loops etc. require a body, so you place a pass there when you want to leave the implementation for later.

    def myfunction(a, b, c):
        pass # im doing this later
    

    In Lua, however, this is not necessary. It is perfectly fine to end an if or a function without including any body, so there is no need for a pass in Lua.

    function myfunction(a, b, c)
        -- im doing this later
    end