2 ms·
> Named arguments is okay I suppose, but IDEs solve knowing the order of arguments. Named arguments are incredibly helpful for functions with a bunch of option
by duskwuff 6y ago
> Named arguments is okay I suppose, but IDEs solve knowing the order of arguments.
Named arguments are incredibly helpful for functions with a bunch of optional parameters, like setcookie() -- instead of
setcookie("cookiename", "value", 0, "", "", false, true);
to set httponly (the last argument), you can now skip over the unused parameters and write:
setcookie("cookiename", "value", httponly: true);
Not only is this more concise, but it's also self-documenting!
- donatj 6y agoI would have personally been happy with setcookie("cookiename", "value", , , , , true); As I used in VB.Net 15 years ago, I have no idea if other languages (C#?) support that