[前][次][番号順一覧][スレッド一覧]

ruby-changes:25057

From: zzak <ko1@a...>
Date: Sun, 7 Oct 2012 04:38:30 +0900 (JST)
Subject: [ruby-changes:25057] zzak:r37109 (trunk): * string.c (rb_str_match):

zzak	2012-10-07 04:38:18 +0900 (Sun, 07 Oct 2012)

  New Revision: 37109

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37109

  Log:
    * string.c (rb_str_match):
      Clarify behavior for captured strings and local variable assignment
      Patch by Marcus Stollsteimer [ruby-dev:47668] [Bug #7062]

  Modified files:
    trunk/string.c

Index: string.c
===================================================================
--- string.c	(revision 37108)
+++ string.c	(revision 37109)
@@ -2699,6 +2699,10 @@
  *  <i>obj.=~</i>, passing <i>str</i> as an argument. The default
  *  <code>=~</code> in <code>Object</code> returns <code>nil</code>.
  *
+ *  Note: <code>str =~ regexp</code> is not the same as
+ *  <code>regexp =~ str</code>. Strings captured from named capture groups
+ *  are assigned to local variables only in the second case.
+ *
  *     "cat o' 9 tails" =~ /\d/   #=> 7
  *     "cat o' 9 tails" =~ 9      #=> nil
  */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]