Hello -- On Sun, 19 May 2002, Michael Campbell wrote: > > Look on the bright side: > > > > str = gets > > matched, x, y = str.match /^\s*(\S+)\s+(\S+)\s*$/ > > if matched > > puts "You typed the words #{x} and #{y}." > > else > > puts "You didn't type two separate words." > > end > > > > and such. The MatchData object really isn't such a bad thing :-) > > No more "bad thing" than necessary though. > > YOu could just as easily check "x" or "y" instead of "matched" in > your above snippet. > > I'm probably in the minority and I'm ok with that, but #match > matching n things but returning n+1 values breaks MY worldview of > "least astonishment". Remember though: what's really being matched is the whole pattern, while the ()-captures are really just submatches. So #match is really matching 1 thing (the pattern), plus returning meta-information about n sub-things. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav