lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jul 9, 2014 at 5:05 PM, Coroutines <coroutines@gmail.com> wrote:

> The spaceship operator is my favorite ("<=>"):
> https://en.wikipedia.org/wiki/Spaceship_operator

Another fun one is the NULL coalescing operator found in some languages.

In Lua you handle default args like:

if default_arg then
    default_arg = 3
end

-- or

default_arg = default_arg or 3

(let's pretend I'm comparing against nil for best practices)

Anyway, C# has "??" to do that: default_arg = default_arg ?? 3;

https://en.wikipedia.org/wiki/Null_coalescing_operator