1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* doc/re.rdoc: Completed wording in the description of the =~ operator.

[ruby-trunk - Bug #6529]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2012-06-08 23:17:00 +00:00
parent 9fa6147b9c
commit a60a58b183
2 changed files with 12 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Sat Jun 9 08:16:47 2012 Eric Hodel <drbrain@segment7.net>
* doc/re.rdoc: Completed wording in the description of the =~ operator.
[ruby-trunk - Bug #6529]
Sat Jun 9 08:09:38 2012 Eric Hodel <drbrain@segment7.net> Sat Jun 9 08:09:38 2012 Eric Hodel <drbrain@segment7.net>
* string.c (rb_str_start_with): Removed "p" from start_with? examples * string.c (rb_str_start_with): Removed "p" from start_with? examples

View file

@ -32,11 +32,15 @@ method.
=== <tt>=~</tt> operator === <tt>=~</tt> operator
<tt>=~</tt> is Ruby's basic pattern-matching operator. When one operand is a <tt>=~</tt> is Ruby's basic pattern-matching operator. When one operand is a
regular expression and is a string (this operator is equivalently defined by regular expression and the other is a string then the regular expression is
Regexp and String). If a match is found, the operator returns index of first used as a pattern to match against the string. (This operator is equivalently
match in string, otherwise it returns +nil+. defined by Regexp and String so the order of String and Regexp do not matter.
Other classes may have different implementations of <tt>=~</tt>.) If a match
is found, the operator returns index of first match in string, otherwise it
returns +nil+.
/hay/ =~ 'haystack' #=> 0 /hay/ =~ 'haystack' #=> 0
'haystack' =~ /hay/ #=> 0
/a/ =~ 'haystack' #=> 1 /a/ =~ 'haystack' #=> 1
/u/ =~ 'haystack' #=> nil /u/ =~ 'haystack' #=> nil