From: timsuth@... (Tim Sutherland) Date: 2004-04-26T18:29:08+09:00 Subject: Re: Propose Range.new(..., &succ) In article <20040424171959.48054.qmail@web60903.mail.yahoo.com>, Jeff Mitchell wrote: >The other day I had > >(5..8).map { |x| > # stuff >}.other_stuff > >and at some point I wanted x to be in increments of 0.5. What to do? >Well I could be silly and define Float#succ. Short of that, I need to >change the code to either > >accum = [] >5.step(8, 0.5) { |x| > accum << > # stuff >} >accum.other_stuff [...] As an alternative, (0..10.0).step(0.5) { |x| # stuff } Note that at least one of the ends of the range must be a Float (rather than an Integer), otherwise you will get a "ArgumentError: step can't be 0" exception. -- Tim Sutherland 2004 SDKACM President Software Developers' Klub - the University of Auckland ACM Student Chapter http://www.sdkacm.com/