< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #15590 has been updated by shevegen (Robert A. Heiler).
After re-reading, I think you may refer more to a method such as:
.duplicates?
on class Array, right?
If this is the case then I understand your example and proposal and
I am slightly in favour (if it is meant as a complementary method to
.uniq; at the least I remember that I had to do this a few times to
detect the duplicate entries, e. g. faulty files that may keep track of
dependencies for programs to compile, and had twice the same content
in the same .yml file; I am sure others may have had somewhat
similar use cases here and there - but again, right now I am not
100% sure if this is what Eric suggested actually).
----------------------------------------
Feature #15590: Add dups to Array to find duplicates
https://bugs.ruby-lang.org/issues/15590#change-76687
* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Many times I find myself debugging data and the need of finding duplicated values inside of an Array.
Based on the amount of data it could be a simple `array.detect { |value| array.count(value) > 1 }` or a more performant way like
```ruby
def dups_for(array)
duplicated_values = []
tmp = {}
array.each do |value|
duplicated_values << value if tmp[value]
tmp[value] = true
end
duplicated_values
end
```
It would be awesome if there was a way directly from the core language to call `dups` (or another name, as it could be too similar to the current `dup`) on an array in order to get all the duplicated values.
I'd love to create a PR for this, but my C level is non-existent
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>