Module:Yesno/doc: Difference between revisions

Content deleted Content added
I have just made many attempts, there is no code that handles the "nil" case properly AND simply; as a reminder, Lua's "and/or pseudo-ternary" doesn't exactly behaves like real "?:" ternaries, and that's problematic here; I would suggest to handle the "nil" case really separately, e.g. « if value == nil then myvariable = true/false else myvariable = yesno(value) end », as it's the simplest actually
Line 107:
<syntaxhighlight lang="lua">
myvariable = yesno(value or false) -- When value is nil, result is false.
myvariable = yesno(value or true) -- When value is nil, result is true. (XXX: when value is false, result is true...)
myvariable = yesno('foo') or false -- Unknown string returns nil, result is false.
myvariable = yesno('foo', true) or false -- Default value (here: true) applies, result is true.