Merci, ADZE_CNC!adze_cnc wrote: ↑Wed Nov 20, 2024 7:46 pmOne thing to watch out for is the function ifT(x)
It will behave oddly if presented a non-Boolean value:
You could add...Code: Select all
print(ifT("abc")) -- returns: Yes print(ifT(123.56)) -- returns: Yes print(ifT(nil)) -- returns: No
...to catch passing non-Boolean values during testing.Code: Select all
assert(type(x) == "boolean", "Argument must be a true or false value.")
You could also use:
To tighten things up a bit.Code: Select all
function ifT(x) assert(type(x) == "boolean", "Argument must be a true or false value.") return x and "yes" or "no" end
I have entered the tighten things up a bit Option to the Code.
Cheers,
Sharkcutup