Hacker News new | ask | show | jobs
by klankeser 419 days ago
I would recommend reading the article example once more. Going from the example, without the overload, the function would return a union type which means any time you use the function, you have to put a type check to the result to know if the output is a list or not. With overload, as soon as an argument to the function is a certain type, the output is determined, so you won't need to type check.
1 comments

I think that GP's point is that you could accomplish the same thing by simply having separate functions with different names, signatures, and return types.