Project

General

Profile

Actions

Bug #14082

closed

Enumerator#size from Enumerable#cycle returns 0 when the object is empty

Added by kachick (Kenichi Kamiya) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
[ruby-core:83680]

Description

github: https://github.com/ruby/ruby/pull/1742

Is this an intentional behavior?

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0