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)
:: Sinq

Shoot, that's simple. Thank you!

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

<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 2020-05-28 19:09 | 0.010s | 2097k | Q:18