Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: