Project

General

Profile

Actions

Bug #18793

closed

Select and Find behave differently for hashes

Added by brenogazzola (Breno Gazzola) almost 2 years ago. Updated almost 2 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:108639]

Description

It seems that Hash implements select but not find, which uses the Enumerable version.

irb(main):009:0> { 1..10 => :a, 11 .. 20 => :b }.select { _1 === 12 }
=> {11..20=>:b}

irb(main):010:0> { 1..10 => :a, 11 .. 20 => :b }.find { _1 === 5 }
=> nil

irb(main):011:0> { 1..10 => :a, 11 .. 20 => :b }.select { p _1 }
1..10
11..20

irb(main):012:0> { 1..10 => :a, 11 .. 20 => :b }.find { p _1 }
[1..10, :a]

Expected Behavior:
I expected that both select and find return matches OR that neither select and find return matches

Current Behavior:
Select returns matches but find does not.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0