From c6706f15af123bdbb3b39a21903d85c78462d047 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 5 Oct 2021 08:39:27 -0700 Subject: 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] --- string.c | 19 ++++++++++--------- 1 file 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. */ -- cgit v1.2.3