summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-10-05 08:39:27 -0700
committerJeremy Evans <code@jeremyevans.net>2021-10-05 08:39:27 -0700
commitc6706f15af123bdbb3b39a21903d85c78462d047 (patch)
treecbf466c8dbbaea6f1cf748dbd0e28d04029c9e37 /string.c
parentf2ca65266f203da8a8c3afa734bb6e76a088c581 (diff)
Fix documentation for String#{<<,concat,prepend}
These methods mutate and return the receiver, they don't create and return a new string. Fixes [Bug #18241]
Diffstat (limited to 'string.c')
-rw-r--r--string.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/string.c b/string.c
index 1f143853e4..f95722b8d4 100644
--- a/string.c
+++ b/string.c
@@ -3171,13 +3171,13 @@ rb_str_concat_literals(size_t num, const VALUE *strary)
/*
* call-seq:
- * string.concat(*objects) -> new_string
+ * string.concat(*objects) -> string
*
- * Returns a new \String containing the concatenation
- * of +self+ and all objects in +objects+:
+ * Concatenates each object in +objects+ to +self+ and returns +self+:
*
* s = 'foo'
* s.concat('bar', 'baz') # => "foobarbaz"
+ * s # => "foobarbaz"
*
* For each given object +object+ that is an \Integer,
* the value is considered a codepoint and converted to a character before concatenation:
@@ -3209,12 +3209,13 @@ rb_str_concat_multi(int argc, VALUE *argv, VALUE str)
/*
* call-seq:
- * string << object -> str
+ * string << object -> string
+ *
+ * Concatenates +object+ to +self+ and returns +self+:
*
- * Returns a new \String containing the concatenation
- * of +self+ and +object+:
* s = 'foo'
* s << 'bar' # => "foobar"
+ * s # => "foobar"
*
* If +object+ is an \Integer,
* the value is considered a codepoint and converted to a character before concatenation:
@@ -3289,12 +3290,12 @@ rb_str_concat(VALUE str1, VALUE str2)
/*
* call-seq:
- * string.prepend(*other_strings) -> str
+ * string.prepend(*other_strings) -> string
*
- * Returns a new \String containing the concatenation
- * of all given +other_strings+ and +self+:
+ * Prepends each string in +other_strings+ to +self+ and returns +self+:
* s = 'foo'
* s.prepend('bar', 'baz') # => "barbazfoo"
+ * s # => "barbazfoo"
*
* Related: String#concat.
*/