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

ruby-changes:19851

From: ryan <ko1@a...>
Date: Thu, 2 Jun 2011 07:29:18 +0900 (JST)
Subject: [ruby-changes:19851] ryan:r31898 (trunk): Clarified String#tr rdoc. (RickHull)

ryan	2011-06-02 07:29:09 +0900 (Thu, 02 Jun 2011)

  New Revision: 31898

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

  Log:
    Clarified String#tr rdoc. (RickHull)

  Modified files:
    trunk/string.c

Index: string.c
===================================================================
--- string.c	(revision 31897)
+++ string.c	(revision 31898)
@@ -5228,19 +5228,22 @@
 
 /*
  *  call-seq:
- *     str.tr(from_str, to_str)   -> new_str
+ *     str.tr(from_str, to_str)   => new_str
  *
- *  Returns a copy of <i>str</i> with the characters in <i>from_str</i> replaced
- *  by the corresponding characters in <i>to_str</i>. If <i>to_str</i> is
- *  shorter than <i>from_str</i>, it is padded with its last character. Both
- *  strings may use the c1--c2 notation to denote ranges of characters, and
- *  <i>from_str</i> may start with a <code>^</code>, which denotes all
+ *  Returns a copy of <i>str</i> with the characters in <i>from_str</i> 
+ *  replaced by the corresponding characters in <i>to_str</i>. If 
+ *  <i>to_str</i> is shorter than <i>from_str</i>, it is padded with its last
+ *  character in order to maintain the correspondence.
+ *
+ *     "hello".tr('el', 'ip')      #=> "hippo"
+ *     "hello".tr('aeiou', '*')    #=> "h*ll*"
+ * 
+ *  Both strings may use the c1-c2 notation to denote ranges of characters,
+ *  and <i>from_str</i> may start with a <code>^</code>, which denotes all
  *  characters except those listed.
  *
- *     "hello".tr('aeiou', '*')    #=> "h*ll*"
+ *     "hello".tr('a-y', 'b-z')    #=> "ifmmp"
  *     "hello".tr('^aeiou', '*')   #=> "*e**o"
- *     "hello".tr('el', 'ip')      #=> "hippo"
- *     "hello".tr('a-y', 'b-z')    #=> "ifmmp"
  */
 
 static VALUE

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

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