Project

General

Profile

Actions

Bug #21124

closed

Enumerable#find called without a block returns Enumerator without size

Added by andrykonchin (Andrew Konchin) 5 days ago. Updated 2 days ago.

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

Description

When a collection's size is known then enumerator that iterates it usually has size (that's #size returns a collection size).

But an enumerator returned by Enumerable#find called without a block doesn't have size:

[1, 2, 3].find.size # => nil

Expected result here is 3.

Usually similar methods in the Enumerable module return enumerators with size (when these enumerators for instance iterate the collection itself):

[1, 2, 3].each_entry.size # => 3
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0