4 ms·
I disagree. I think that this type of "late type binding" is actually an advantage of dynamically typed languages. That way it does not matter if you pass a map
by naranha 10y ago
I disagree. I think that this type of "late type binding" is actually an advantage of dynamically typed languages. That way it does not matter if you pass a map/array/dictionary or an instance of a class as long as the properties are the same.
- chrisseaton 10y agoI think one problem is when your object quacks like a duck, but the quack doesn't mean what you think it means. Having methods that just have the right names is a pretty weak assurance, isn't it?
- zodiac 10y agoThe type hinting is optional, so if you want "late type binding" you can just omit the type hints.
- spdionis 10y ago"Fail Fast" is a pretty popular best-practice and failing immediately on a mismatched type hint is in line with that.
- vertex-four 10y agoThen... don't specify that you want a specific type?