[ruby-core:105747] [Ruby master Bug#18261] String#prepend inconsistent documentation
From:
"greggzst (Grzegorz Jakubiak)" <noreply@...>
Date:
2021-10-22 08:45:32 UTC
List:
ruby-core #105747
Issue #18261 has been reported by greggzst (Grzegorz Jakubiak).
----------------------------------------
Bug #18261: String#prepend inconsistent documentation
https://bugs.ruby-lang.org/issues/18261
* Author: greggzst (Grzegorz Jakubiak)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.2
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I noticed documentation at https://docs.ruby-lang.org/en/3.0.0/String.html#method-i-prepend says:
```
Returns a new String containing the concatenation of all given other_strings and self:
```
but `String#prepend` modifies string in place; code example:
```ruby
[1] pry(main)> string = 'my_string'
=> "my_string"
[2] pry(main)> string.object_id
=> 135120
[3] pry(main)> string.prepend('prefix_').object_id
=> 135120
[4] pry(main)> string
=> "prefix_my_string"
```
I checked the docs in the `string.c` file on github and they are actually correct:
```
Prepends each string in +other_strings+ to +self+ and returns +self+:
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>