News for hackers. Stuff that matters.
Re:"Useless Ruby sugar": Argument forwarding by djur on Friday November 24, 2023 @02:44PM (#38407440)
The language didn't have keyword arguments at the time it was originally created (nor did many other languages). The use of hashes as a way of simulating them was popular at the time (I've seen the same in Perl) but it was a good idea to eventually make them a full-fledged feature. It took a while to complete that transition without causing a serious backwards-incompatible disruption. Ruby has generally favored avoiding such things, which sometimes means finding some inelegant solutions.
Re:"Useless Ruby sugar": Argument forwarding by throwanem on Friday November 24, 2023 @03:13PM (#38407729)
> it was a good idea to eventually make them a full-fledged feature

Why so?

Re:"Useless Ruby sugar": Argument forwarding by vidarh on Friday November 24, 2023 @04:35PM (#38408636)
Because it provides a clearer way of enforcing calling conventions. Calling a method with the wrong keyword argument raises an error automatically. Calling a method with hash arguments the method expect replies on the method manually checking for unexpected keys. In Ruby as in other languages it was error prone.
Re:"Useless Ruby sugar": Argument forwarding by gls2ro on Saturday November 25, 2023 @03:18AM (#38412109)
Positional arguments creates a dependency on the position of the argument. And this is a cause of bugs when calling a method with the arguments in the wrong order.

Keyword arguments remove the depedency on the position.