Project

General

Profile

Actions

Feature #5551

closed

Enumerable#rdrop

Added by sawa (Tsuyoshi Sawada) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-dev:44777]

Description

There is Enumerable#drop(n), which drops elements on the left side, but there is no counterpart for dropping the right side. It will be convenient if there is Enumerable#rdrop(n) that drops the elements on the right side.

[1, 2, 3, 4, 5].rdrop(2) # => [1, 2, 3]

Updated by nobu (Nobuyoshi Nakada) over 12 years ago

なかだです。

(11/11/03 3:18), Tsuyoshi Sawada wrote:

There is Enumerable#drop(n), which drops elements on the left side, but there is no counterpart for dropping the right side. It will be convenient if there is Enumerable#rdrop(n) that drops the elements on the right side.

[1, 2, 3, 4, 5].rdrop(2) # => [1, 2, 3]

Enumerableは逆方向の操作を提供していませんし、無限リストも作れますから、
ArrayのメソッドにするかEnumeratorで遅延評価でもするようにしないと無理で
しょう。

--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦

Updated by sawa (Tsuyoshi Sawada) over 12 years ago

中田さんのコメントにあるような方向性(のどちらか)でいくのがよいと思います。

Updated by matz (Yukihiro Matsumoto) over 12 years ago

  • Status changed from Open to Rejected

Arrayに追加するのであれ、Enumeratorで遅延評価するのであれ、この提案の根幹部分の変更になりますので、いったんrejectします。
また、思いついたrandom ideasをなんでもRubyに入れようとするのでなく、なぜそれを入れると良いのかという部分を説明していただけると採用しやすいと思います。現時点ではrdropの嬉しさがよくわからないので、Array#rdropとか採用しにくいです。

まず、ActiveSupportに入れたら、とか思っちゃいます。

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0