From: Daniel Brockman Date: 2005-07-29T09:58:38+09:00 Subject: Re: Idea for Ruby 2.0 Nikolai, > Lately I've found myself using pseudo-anonymous variables > a lot, e.g., something like this: > > [[1, 2], [2, 3], [3, 4]].each{ |first, _| fs << first } > > The idea is that I'm not interested in the second part of > the internal arrays, only the first. The lowline works, > but obviously for one parameter, as it is a > valid identifier. Interestingly, blocks can have duplicate argument names, {1=>2}.each {|_,_| puts _} #=> 2 but methods can't: def foo _,_ ; end #=> SyntaxError > I was thinking whether Ruby 2.0 should introduce > I-don't-care-type variables, like Haskell or Prolog has. As you said, it would be useful when *passing* arguments, and it's obviously useful in blocks. I can see how it could be worthwhile to allow it in method definitions too --- for symmetry if nothing else. > It would make all identifiers beginning with a lowline > invalid, except in parameter-lists, As others have pointed out, I'd think just one identifer would need to be reserved: the single-underscore one. > which could mean too much incompatability with Ruby 1.x, > but perhaps it's worth at least some thought? Even reserving just the single-underscore identifier would mean some incompatibility, but then you *did* put "Ruby 2.0" in the subject line. :-) -- Daniel Brockman So really, we all have to ask ourselves: Am I waiting for RMS to do this? --TTN.