[ruby-core:86190] [Ruby trunk Bug#14082] Enumerator#size from Enumerable#cycle returns 0 when the object is empty

From: usa@...
Date: 2018-03-18 15:33:42 UTC
List: ruby-core #86190
Issue #14082 has been updated by usa (Usaku NAKAMURA).

Backport changed from 2.3: REQUIRED, 2.4: DONE to 2.3: DONE, 2.4: DONE

ruby_2_3 r62827 merged revision(s) 60666,60667,60668.

----------------------------------------
Bug #14082: Enumerator#size from Enumerable#cycle returns 0 when the object is empty
https://bugs.ruby-lang.org/issues/14082#change-71077

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
* ruby -v: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
* Backport: 2.3: DONE, 2.4: DONE
----------------------------------------
github: https://github.com/ruby/ruby/pull/1742

Is this an intentional behavior?

```ruby
p([].cycle.size) #=> 0
p({}.cycle.size) #=> Infinity 
```

Array#cycle already special handled empty arrays. So similar behavior in Enumerable#cycle with the #size sounds reasonable to me.



-- 
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>

In This Thread

Prev Next