This is a good example of the little inconsequential details that I love about Ruby. As much as I sometimes dislike the way things are done in the community, I always respect this attention to detail. It contrasts with the PHP approach of "what symbol is available to shoehorn in this new functionality", not to pick on PHP but that's where I spent half my professional life.
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.
> 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.
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.
Ruby also lets you do this in function definitions. Python doesn't special-case the underscore like Ruby does -- while I have occasionally wished otherwise, it is at least consistent with Python's language design principles that the special case doesn't exist.
I don't have a source for this, but it is my understanding that, even though the python interpreter doesn't special-case the "_" variable name, it is a convention to use the underscore in the same situations in python as are described in ruby in the article.
Apart from the special meaning of the underscore in interactive mode, and the function _() in Django, I don't think it's common to use _ as a placeholder in Python. I sometimes do it regardless, hoping its meaning should be clear enough, but it's less suitable than in Ruby because you can't use it to ignore multiple arguments.