Project

General

Profile

Actions

Bug #19231

open

Integer#step and Float::INFINITY - inconsistent behaviour when called with and without a block

Added by andrykonchin (Andrew Konchin) over 1 year ago. Updated 15 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:111272]

Description

The initial issue was reported here https://github.com/oracle/truffleruby/issues/2797.

0.step(Float::INFINITY, 10) returns:

  • Integers when called with a block
  • Floats when called without a block

I would expect Floats to be returned in both cases.

Examples:

0.step(Float::INFINITY, 10).take(1).map(&:class)
=> [Float]
0.step(Float::INFINITY, 10) { |offset| p offset.class; break }
# Integer

When to argument is a finite Float value then calling with a block returns Floats as well:

0.step(100.0, 10) { |offset| p offset.class; break }
# Float

Wondering whether it's intentional behaviour.

I've found a related issue https://bugs.ruby-lang.org/issues/15518.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0