If you need something of a certain type, otherwise it breaks, then check its type or force it to the appropriate type. If value is also a problem, you should also check its value.
In fact, it all depends on the source of your arguments. If this is just your code, then there should be no reason to type check if your code is correctly written. If it is an external source (i.e. you are writing a library function or one that accepts user input), you should check this argument.
Simply put, check types when you have a reason to expect them to not be of the appropriate type. Otherwise, just write your code so that there are no type mismatches.
Rejecting dynamic typing will force you to ultimately struggle with the language, rather than using it.
source share