ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "mame (Yusuke Endoh)" <mame@tsg.ne.jp>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:44069] [ruby-trunk - Feature #6240][Assigned] Enumerable#drop with negative argument
Date: Mon, 2 Apr 2012 22:59:46 +0900	[thread overview]
Message-ID: <redmine.journal-25602.20120402225945@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-6240.20120401055741@ruby-lang.org


Issue #6240 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)


----------------------------------------
Feature #6240: Enumerable#drop with negative argument
https://bugs.ruby-lang.org/issues/6240#change-25602

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 2.0.0


Currently, Enumerable#drop works only for non-negative arguments.

It could be extended so that negative arguments means dropping from the end:

    [:hello, :world].drop(-1) # => [:hello]

This could especially be interesting for `Lazy#drop`, which would keep a circular buffer of elements before yielding them.

    (1..6).lazy.drop(-3).each{|x| puts x} # -> prints 1, 2 and 3

Thoughts?


-- 
http://bugs.ruby-lang.org/

  parent reply	other threads:[~2012-04-02 14:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-31 20:57 [ruby-core:44028] [ruby-trunk - Feature #6240][Open] Enumerable#drop with negative argument marcandre (Marc-Andre Lafortune)
2012-04-01  0:05 ` [ruby-core:44030] [ruby-trunk - Feature #6240] " shugo (Shugo Maeda)
2012-04-01 23:38 ` [ruby-core:44047] " marcandre (Marc-Andre Lafortune)
2012-04-02  1:41 ` [ruby-core:44051] " shugo (Shugo Maeda)
2012-04-02 13:59 ` mame (Yusuke Endoh) [this message]
2012-10-25  8:48 ` [ruby-core:48242] " yhara (Yutaka HARA)
2019-01-10  8:30 ` [ruby-core:90982] [Ruby trunk Feature#6240] " knu
2019-01-10 23:07 ` [ruby-core:91006] [Ruby trunk Feature#6240][Closed] " ruby-core

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=redmine.journal-25602.20120402225945@ruby-lang.org \
    --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).