3 ms·
Only after you have tried to call the function with an array many times, that's when it would make sense. And there's another option too, to instead add a check
by z3t4 7y ago
Only after you have tried to call the function with an array many times, that's when it would make sense. And there's another option too, to instead add a check and a friendly error. But it should be a fairly rare thing to do.
Naming things can be hard and maybe more so if you do not have type annotations. But being used to dynamic languages I always find type annotations a chore. And I think it's better to have a good name and no types, then a bad name and types. eg. max(...numbers) vs x(y:number, z:number) -> number . Even though x is more verbose it can be anything, but with max(...numbers) I can be fairly sure.
- mgraczyk 7y agobut then you have to test for this behavior, which was the counterpoint to the article.