From: "andrykonchin (Andrew Konchin) via ruby-core" Date: 2025-02-08T22:13:19+00:00 Subject: [ruby-core:120914] [Ruby master Bug#21124] Enumerable#find called without block returns Enumerator without size Issue #21124 has been reported by andrykonchin (Andrew Konchin). ---------------------------------------- Bug #21124: Enumerable#find called without block returns Enumerator without size https://bugs.ruby-lang.org/issues/21124 * Author: andrykonchin (Andrew Konchin) * Status: Open * ruby -v: 3.4.1 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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: ```ruby [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): ```ruby [1, 2, 3].each_entry.size # => 3 ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/