4 ms·
For me the core issue seems to be that the map function has, in essence, three overloads which does very different things. A strongly typed compiler would not
by magicalhippo 6y ago
For me the core issue seems to be that the map function has, in essence, three overloads which does very different things.
A strongly typed compiler would not catch the error in the article with a similarly overloaded map function, so type checking can't really rescue you from this situation.
Sure the chances of it happening silently might be slightly less, as the second and third parameter would have to match in type (integers in this case), but it could still absolutely happen silently.
So to me the core take-away is that overloading a function in such a way is a very poor design choice, regardless of language.