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

ruby-changes:63301

From: Burdette <ko1@a...>
Date: Fri, 9 Oct 2020 05:35:39 +0900 (JST)
Subject: [ruby-changes:63301] 33776598f7 (master): Enhanced RDoc for String#insert (#3643)

https://git.ruby-lang.org/ruby.git/commit/?id=33776598f7

From 33776598f70dc0adfd7b0d62a0a0df2e2c36b172 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Thu, 8 Oct 2020 15:35:13 -0500
Subject: Enhanced RDoc for String#insert (#3643)

* Enhanced RDoc for String#insert

diff --git a/string.c b/string.c
index d57d949..556b03a 100644
--- a/string.c
+++ b/string.c
@@ -4611,6 +4611,8 @@ rb_str_aref(VALUE str, VALUE indx) https://github.com/ruby/ruby/blob/trunk/string.c#L4611
  *    string[regexp, capture = 0] -> new_string or nil
  *    string[substring] -> new_string or nil
  *
+ *  Returns the substring of +self+ specified by the arguments.
+ *
  *  When the single \Integer argument +index+ is given,
  *  returns the 1-character substring found in +self+ at offset +index+:
  *    'bar'[2] # => "r"
@@ -4915,19 +4917,17 @@ rb_str_aset_m(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L4917
 
 /*
  *  call-seq:
- *     str.insert(index, other_str)   -> str
- *
- *  Inserts <i>other_str</i> before the character at the given
- *  <i>index</i>, modifying <i>str</i>. Negative indices count from the
- *  end of the string, and insert <em>after</em> the given character.
- *  The intent is insert <i>aString</i> so that it starts at the given
- *  <i>index</i>.
- *
- *     "abcd".insert(0, 'X')    #=> "Xabcd"
- *     "abcd".insert(3, 'X')    #=> "abcXd"
- *     "abcd".insert(4, 'X')    #=> "abcdX"
- *     "abcd".insert(-3, 'X')   #=> "abXcd"
- *     "abcd".insert(-1, 'X')   #=> "abcdX"
+ *    string.insert(index, other_string) -> self
+ *
+ *  Inserts the given +other_string+ into +self+; returns +self+.
+ *
+ *  If the \Integer +index+ is positive, inserts +other_string+ at offset +index+:
+ *    'foo'.insert(1, 'bar') # => "fbaroo"
+ *
+ *  If the \Integer +index+ is negative, counts backward from the end of +self+
+ *  and inserts +other_string+ at offset <tt>index+1</tt>
+ *  (that is, _after_ <tt>self[index]</tt>):
+ *    'foo'.insert(-2, 'bar') # => "fobaro"
  */
 
 static VALUE
-- 
cgit v0.10.2


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

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