News for hackers. Stuff that matters.
Re:Ruby’s magic underscore by anonymouz on Saturday September 22, 2012 @11:35AM (#4558039)
I'm sorry, but special casing a variable name like this seems to be something that, in the long term, leads to a messy, overly complex, language and lots of traps for newcomers.

Is there any reason while the Ruby 1.8 behaviour that duplicate variable names are allowed was changed? This seems a much cleaner way of allowing this construct.

Re:Ruby’s magic underscore by msbarnett on Saturday September 22, 2012 @05:15PM (#4559010)
> Is there any reason while the Ruby 1.8 behaviour that duplicate variable names are allowed was changed?

Because in general allowing duplicate argument names is a terrible idea and a rich source of bugs?

> This seems a much cleaner way of allowing this construct.

I feel the exact opposite. A privileged 'disregard' symbol gives you the power of signalling that you don't care about certain arguments, without the 'shoot-yourself-in-the-foot' side effect of easily accidentally shadowing what you intended to be distinct entities.

Re:Ruby’s magic underscore by anonymouz on Sunday September 23, 2012 @03:48AM (#4560348)
I can see the argument for having a special symbol for this - but that is not what's happening here. The underscore is still a perfectly valid variable name and is used as such, only it behaves different from every other variable name. If it's supposed to be a special symbol don't make it a valid variable name.
Re:Ruby’s magic underscore by pcwalton on Saturday September 22, 2012 @01:33PM (#4558421)
Well, for one, special-casing _ allows for an unused-variable warning in the future (although I have no idea whether Ruby's semantics allow for this).