Log In  

Can I/what syntax should be used to specify default values for the parameters of a function?

P#49573 2018-02-23 18:02 ( Edited 2018-02-24 03:05)

function func(param)
    param = param or 42
    print(param)
end

func(36)
-->36
func()
-->42
P#49574 2018-02-23 18:19 ( Edited 2018-02-23 23:19)

Shoot, that's simple. Thank you!

P#49576 2018-02-23 18:26 ( Edited 2018-02-23 23:26)

<3 this about Lua

P#49585 2018-02-23 22:05 ( Edited 2018-02-24 03:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-16 19:58:28 | 0.006s | Q:14