3 ms·
> You pass an int into a method that expects a string, what's the expected behavior? Probably an exception, depending on the language. E.g. if the method expec
by goto11 4y ago
> You pass an int into a method that expects a string, what's the expected behavior?
Probably an exception, depending on the language. E.g. if the method expects the argument to support the method "substring()" it would be expected to throw an exception if the passed object does not have such a method.
If you pass an object which support the expected interface but with a completely different semantics, then you probably get a weird unexpected behavior. But that would also be the case in a statically typed language.