Conditionals
Default Values
Smart use of the 'or' operator instead of nil checks increases readability.
BAD if name then
return name
else
return "John Doe"
end
GOOD return name or "John Doe"
Don't write "if true then return true"
Just use ternary operators to evaluate the expression
BAD if name == "mark" or name == "stacy"
return true
else
return false
end
GOOD return name == "mark" or name == "stacy" -- Will return true if name is either mark or stacy