From: sawadatsuyoshi@... Date: 2015-12-09T12:34:05+00:00 Subject: [ruby-core:71995] [Ruby trunk - Feature #11781] Would it be possible to alias .prepend() towards .unshift() for class Array by default? Issue #11781 has been updated by Tsuyoshi Sawada. `String#prepend` and `String#concat` are a pair that work similarly (with just the difference on where the new substring is inserted). And since there is already `Array#concat`, introducing `Array#prepend` would suggest that they should work similarly. However, while `Array#concat` takes an array and uses that as sub-array of the original array, the proposed `Array#prepend` takes an element and uses that as an element of the original array. This is higly confusing. I don't think the proposal is good. ---------------------------------------- Feature #11781: Would it be possible to alias .prepend() towards .unshift() for class Array by default? https://bugs.ruby-lang.org/issues/11781#change-55406 * Author: Robert A. Heiler * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Hello. For Strings we can do: abc = 'world!' abc[0,0] = 'Hello ' abc # => "Hello world!" For Arrays we can do: abc = ['world!'] abc[0,0] = 'Hello ' abc # => ["Hello ", "world!"] This is nice. For Strings we can also use .prepend() to add to the beginning. For Arrays, we have to use .unshift(). I have a hard time remembering .unshift though, .prepend() seems to be easier for me to remember. I'd like to use both .prepend for Strings and Arrays; right now I have to use different names. I could alias prepend to unshift for class Array, but then I'd have to carry these modifications into my projects, which is not so good - I would prefer to just stick to what MRI is doing. Could we have the alias .prepend() for class Array, meaning .unshift() too? That way I could use .prepend() for both Arrays and Strings. Thanks for reading! -- https://bugs.ruby-lang.org/