Hi,
In message "[ruby-talk:00887] Re: local / dynamic variables"
on 99/10/30, ts <decoux / moulon.inra.fr> writes:
| I'm always surprised (I came from perl) :-)
Perl and Ruby are similar, but not same, as you know.
|G> (lines + "\n").each_with_index{|w,i| break if /z/ =~ w}
| Is this equivalent to w =~ /z/ ?
Yes. Both String and Regexp class have the method =~ to match.
In Ruby, using Regexp method (e.g. /z/ =~ w) is preferred way.
Because pattern matching is considered to be the function of the
Regexp class. But in case `String =~ String', the latter string is
considered as the pattern, following the tradition.
| Apparently it has 2 differents node (MATCH2 and MATCH3)
MATCH2 and MATCH3 are just performance tweaking.
matz.