ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Joseph Jones <joeyi5216@gmail.com>
To: Ruby developers <ruby-core@ruby-lang.org>
Cc: <ruby-core@ruby-lang.org>
Subject: [ruby-core:72349] [Ruby trunk - Feature #11781] [Open] Would it be possible to alias .prepend() towards .unshift() for class Array by default?
Date: Thu, 17 Dec 2015 21:13:32 -0700	[thread overview]
Message-ID: <A9778B48-1E62-4494-B6A0-25293170FFC4@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]

Joseph Jones liked your message with Boxer. On December 7, 2015 at 03:12:22 MST, shevegen@gmail.com wrote:Issue #11781 has been reported by Robert A. Heiler.----------------------------------------Feature #11781: Would it be possible to alias .prepend() towards .unshift() for class Array by default?https://bugs.ruby-lang.org/issues/11781* 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() seemsto be easier for me to remember.I'd like to use both .prepend for Strings and Arrays; right nowI have to use different names. I could alias prepend to unshiftfor class Array, but then I'd have to carry these modificationsinto my projects, which is not so good - I would prefer to juststick 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 Arraysand Strings.Thanks for reading!-- https://bugs.ruby-lang.org/     

[-- Attachment #2: Type: text/html, Size: 1857 bytes --]

                 reply	other threads:[~2015-12-18  3:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A9778B48-1E62-4494-B6A0-25293170FFC4@gmail.com \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).