From 14c234ae7345c8c325f0d360548c0c08d2838a4a Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Sat, 27 Sep 2025 19:59:33 +0100 Subject: [PATCH] [DOC] Tweaks for String#prepend --- doc/string.rb | 2 +- string.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/string.rb b/doc/string.rb index c75d171876a1ea..43386c644c80cb 100644 --- a/doc/string.rb +++ b/doc/string.rb @@ -388,6 +388,7 @@ # - #<<: Returns +self+ concatenated with a given string or integer. # - #append_as_bytes: Returns +self+ concatenated with strings without performing any # encoding validation or conversion. +# - #prepend: Prefixes to +self+ the concatenation of given other strings. # # _Substitution_ # @@ -448,7 +449,6 @@ # - #+: Returns the concatenation of +self+ and a given other string. # - #center: Returns a copy of +self+, centered by specified padding. # - #concat: Returns the concatenation of +self+ with given other strings. -# - #prepend: Returns the concatenation of a given other string with +self+. # - #ljust: Returns a copy of +self+ of a given length, right-padded with a given other string. # - #rjust: Returns a copy of +self+ of a given length, left-padded with a given other string. # diff --git a/string.c b/string.c index a5743ceda596ce..81353556c956c0 100644 --- a/string.c +++ b/string.c @@ -4086,15 +4086,14 @@ rb_ascii8bit_appendable_encoding_index(rb_encoding *enc, unsigned int code) /* * call-seq: - * prepend(*other_strings) -> string + * prepend(*other_strings) -> new_string * - * Prepends each string in +other_strings+ to +self+ and returns +self+: + * Prefixes to +self+ the concatenation of the given +other_strings+; returns +self+: * - * s = 'foo' - * s.prepend('bar', 'baz') # => "barbazfoo" - * s # => "barbazfoo" + * 'baz'.prepend('foo', 'bar') # => "foobarbaz" + * + * Related: see {Modifying}[rdoc-ref:String@Modifying]. * - * Related: String#concat. */ static VALUE