Project

General

Profile

Actions

Bug #14082

closed

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

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

Added by kachick (Kenichi Kamiya) almost 8 years ago. Updated over 7 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.

Updated by marcandre (Marc-Andre Lafortune) almost 8 years ago Actions #1 [ruby-core:83682]

  • Assignee set to marcandre (Marc-Andre Lafortune)

Good catch, great patch :-)

Updated by marcandre (Marc-Andre Lafortune) almost 8 years ago Actions #2

  • Status changed from Open to Closed

Applied in changeset trunk|r60666.


Fix size on Enumerable#cycle when the size is 0 [Bug #14082].

Patch by Kenichi Kamiya

Updated by marcandre (Marc-Andre Lafortune) almost 8 years ago Actions #3

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago Actions #4

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

Updated by usa (Usaku NAKAMURA) over 7 years ago Actions #5 [ruby-core:86190]

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

Actions

Also available in: PDF Atom