From: Austin Ziegler Date: 2002-11-02T06:10:17+09:00 Subject: Re: Library consistency On Sat, 2 Nov 2002 05:57:28 +0900, Maur�cio wrote: > Hi, guys, > > Just a sugestion: I think it would be a nice idea if all library > calls that return a regexp match could return a MatchData object. > Today, /regexp/.match, string.gsub and string.scan all return > diferent things. Is that a bad idea for some reason? Each of these has a different purpose, though. Just looking at the two which appear to be related (gsub isn't related because it's supposed to return a replaced string): % ruby -e 'puts /(..)(..)/.match("cruel world")' crue cr ue % ruby -e 'puts "cruel world".scan(/(..)(..)/).join("\n")' cr ue l wo Note that the latter actually returns [['cr', 'ue'], ['l ', 'wo']]. It might be useful to be able to do: /(..)(..)/.scan("cruel world") Which returns an array of MatchData. -austin -- Austin Ziegler, austin@halostatue.ca on 2002.11.01 at 16.01.28