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

in kotlin, named parameters are a good defense against this.

They help in many cases. Mixing named and default parameters in a method, modifying an API without breaking its usage, etc.

It is slightly more verbose, but I tend to use them a lot. Basically everywhere unless the params are obvious (max(a;b) is a good example)



> Basically everywhere unless the params are obvious (max(a;b) is a good example)

This isn't so much "obvious" as "irrelevant"; the arguments to max are all exactly equivalent -- their order can't affect the result.


Expanding on the point a little further, it would be normal from certain mathematical perspectives to see max as a unary function, mapping an unordered (multi)set to the set's maximum element. With one argument, order can't matter because only one order is possible.




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

Search: