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.

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • Assignee set to marcandre (Marc-Andre Lafortune)

Good catch, great patch :-)

Actions #2

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • 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

Actions #3

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED
Actions #4

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

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

Updated by usa (Usaku NAKAMURA) about 6 years ago

  • 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: Atom PDF

Like0
Like0Like0Like0Like0Like0