From: mail@... Date: 2017-10-20T06:43:13+00:00 Subject: [ruby-core:83417] [Ruby trunk Feature#14033] Alias String#<< as String#append Issue #14033 has been updated by sos4nt (Stefan Sch����ler). phluid61 (Matthew Kerwin) wrote: > 1 [...] I would expect that a new word-based name for the dangerous operation would end with "!". That contradicts `Array#append` / `Array#prepend`. And since `String#prepend` also modifies the receiver, I would expect `String#append` to work in a similar way. (Off topic but IMO, `String#concat` is the one that should return a new string, just like the documentation for `String#+` says: _"Concatenation���Returns a new String containing other_str concatenated to str."_ But it's probably a bit late to fix that.) > 2 [...] A method named to look like prepend, but that behaves like concat, is confusing. Good point. I'm fine with string-only arguments. `append` would simply invoke `rb_str_append` then (is that a coincidence?). > 3 [...] this alias would introduce confusion about which method (concat vs. append) has what arity. It should of course work (arity-wise) like `Array#append`, i.e. accept multiple argument. I should have said "concat", not "<<" in the question's title. --- To avoid any further confusion: I'm proposing a _new_ method `String#append` with the following signature: > ### append(other_str1, other_str2,...) ��� str > Append���Append the given strings to _str_. > >```ruby > a = "hello " > a.append("world", "!") #=> "hello world!" > a #=> "hello world!" > ``` > > See also _#concat_. ---------------------------------------- Feature #14033: Alias String#<< as String#append https://bugs.ruby-lang.org/issues/14033#change-67382 * Author: sos4nt (Stefan Sch����ler) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Ruby 2.5 introduces `Array#append` as an alias for `<<` / `push`. Likewise, there should be `String#append` as an alias for `<<` / `concat`. The documentation for `<<` even says "append": > Append���Concatenates the given object to str. [...] And `String` already has a `prepend` method. -- https://bugs.ruby-lang.org/ Unsubscribe: