4 ms·
One solution I've seen is to use two unique string values instead of True/False, and reject all other string values. eg. foo.frob("quick", "loud", "noforc
by ekimekim 12y ago
One solution I've seen is to use two unique string values instead of True/False, and reject all other string values.
eg.
foo.frob("quick", "loud", "noforce")
foo.frob("slow", "sneaky", "force")
foo.frob("fast", "sneaky", "force") # this errors
EDIT: Naturally I'd prefer a type-safe approach in languages that offer it, but this is a common solution I've seen in the python world.