[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev-en:144

From: John Turner <xennocide yahoo.com>
Date: Fri, 14 Jul 2006 12:49:43 +0100
Subject: [yarv-dev-en:144] Re: open> Range bug.

SASADA Koichi wrote:
> Hi,
> 
> John Turner wrote:
>> There's a fairly small bug in range.c that means that a Float step size
>> of between 0 and 1 raises an erroneous exception:
>>
>> irb(main):007:0> RUBY_VERSION
>> => "2.0.0"
>> irb(main):008:0> (0.0..1.0).step(0.1){|i| puts i}
>> ArgumentError: step can't be 0
> 
> It's seems specification.  Range#step only accept Integer.
> 
Sorry I didn't follow this up for so long, Range#step does take float 
values too, as shown by:

irb(main):006:0> RUBY_VERSION
=> "2.0.0"
irb(main):007:0> (0.0..3.0).step(1.1){|i| puts i}
0.0
1.1
2.2
=> 0.0..3.0

It's inconsistent and needs fixing either to actually only accept 
Integers or accept floats correctly.

John

--
ML: yarv-dev-en quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

       127 2006-06-21 16:28 [xennocide yahoo.com ] open> Range bug.                        
       128 2006-06-21 16:33 ┗[ko1 atdot.net       ]                                       
->     144 2006-07-14 20:49  ┗[xennocide yahoo.com ]