Issue #5551 has been reported by Tsuyoshi Sawada.
Feature #5551: Enumerable#rdrop
Author: Tsuyoshi Sawada
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
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]
なかだです。
(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で遅延評価でもするようにしないと無理で
しょう。
Issue #5551 has been updated by Tsuyoshi Sawada.
中田さんのコメントにあるような方向性(のどちらか)でいくのがよいと思います。
Feature #5551: Enumerable#rdrop
Author: Tsuyoshi Sawada
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
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]
Issue #5551 has been updated by Yukihiro M…
Status changed from Open to Rejected
Arrayに追加するのであれ、Enumeratorで遅延評価するのであれ、この提案の根幹部分の変更になりますので、いったんrejectします。
また、思いついたrandom
ideasをなんでもRubyに入れようとするのでなく、なぜそれを入れると良いのかという部分を説明していただけると採用しやすいと思います。現時点ではrdropの嬉しさがよくわからないので、Array#rdropとか採用しにくいです。
まず、ActiveSupportに入れたら、とか思っちゃいます。
Feature #5551: Enumerable#rdrop
Author: Tsuyoshi Sawada
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
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]