Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion spec/tags/core/enumerable/count_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/enumerable/uniq_tags.txt

This file was deleted.

11 changes: 8 additions & 3 deletions src/main/ruby/truffleruby/core/enumerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def count(item = undefined)
seq = 0
if !Primitive.undefined?(item)
warn 'given block not used', uplevel: 1 if block_given?
each { |o| seq += 1 if item == o }
each do
o = Primitive.single_block_arg
seq += 1 if item == o
end
elsif block_given?
each { |o| seq += 1 if yield(o) }
else
Expand Down Expand Up @@ -960,7 +963,8 @@ def uniq(&block)
result = []
if block_given?
h = {}
each do |e|
each do
e = Primitive.single_block_arg
v = yield(e)
unless h.key?(v)
h[v] = true
Expand All @@ -969,7 +973,8 @@ def uniq(&block)
end
else
h = {}
each do |e|
each do
e = Primitive.single_block_arg
unless h.key?(e)
h[e] = true
result << e
Expand Down