Talk:Optional Arguments

From Multi Theft Auto: Wiki

"Optional Arguments have one limitation. You cannot use any optional arguments unless all previous arguments are also supplied."

What if you replace one of the previous arguments with 'nil'? Atleast that works with addBan().

It depends on the function, some support that, some don't. eAi 21:43, 4 January 2011 (UTC)
Lua always passes nil for elements that are not specified so it should work with all functions(cf. Programming in Lua 2nd edition p.36), unless one argument requires another optional argument to work(for example colors, you can not set red to nil and green and blue to 255 and expect it to work) Kamshak 19:18, 4 May 2011 (CEST)
I'm not sure that can apply with C functions, as Lua doesn't know how many arguments these take, so it can't provide nils for them. It's down to our code to handle this case. I may be wrong here though. eAi 19:58, 6 May 2011 (CEST)