From: Matthew Westcott Date: 2004-11-24T23:53:00+09:00 Subject: Block form of 'scan' with one set of parens Hi, Newbieish syntax question - I'm using the block form of 'scan' like this: " ".scan(/<(\w*),(\w*)>/) { |first,second| puts "#{first.upcase} and #{second.upcase}\n" } which works fine. However, if the regex only has one set of parentheses, I can't do " ".scan(/<(\w*)>/) { |first| puts "#{first.upcase}\n" } because it assumes that I want 'first' to be an array of all the matched groups, and so it dies with "undefined method `upcase' for ["bar"]:Array (NameError)". Is there any way to persuade Ruby to treat |first| as a (singleton) list of strings to be assigned? I can use |first,dummy| as a workaround, but is there a neater way that I'm missing? Thanks, - Matthew