Project

General

Profile

Actions

Feature #11090

closed

Enumerable#each_uniq and #each_uniq_by

Added by Hanmac (Hans Mackowiak) almost 9 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:68969]

Description

currently if you want to iterate the first uniq elements you either need to call uniq and create a big array or you need to count the elements yourself
if you have an Enumerable with an indifferent size (maybe something with cycle or something you cant rewind) calling the Array#uniq method might not what you want.

the idea is adding each_uniq which does only iterate though the elements which are not already send (it does count for you)
a second each_uniq_by does work similar with chunk and does takes a block using a generated Enumerator

IceDragon200 did make the following gist/sample in ruby, it might be written in C later to make it faster/better. https://gist.github.com/IceDragon200/5b1c205b4b38665c308e for better view i also added it as attachment.


Files

each_uniq.rb (830 Bytes) each_uniq.rb Hanmac (Hans Mackowiak), 04/23/2015 07:37 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #1153: Enumerable#uniqClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0