On Sun, May 4, 2008 at 11:22 AM, David A. Black <dblack / rubypal.com> wrote:

> > > 2008/5/3  <lovea... / gmail.com>:
> > > >  Where does Ruby store the MatchData if the
> > > >  matching is done in a case statement?
>
>  Matching doesn't change in or out of a case statement; it's still the
>  same thing.

>  Ruby keeps track of the last match operation performed, and that's
>  what you get in $~ (which is a MatchData object) and some of the
>  Regexp class methods.

And $~ is actually a thread local global, so it holds the matchdata
produced by the last successful match on the current thread.

I'm pretty sure that Regexp.last_match is thread-safe as well.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/