Range.generate 
Author Message
 Range.generate

How about defining Range.generate which would return an array:

class Range
  def generate
    ary=[]
    for i in self
      ary << i
    end
    return ary
  end
end

a=(3..5).generate
p a                 # => [3,4,5]

p (3..5).generate   # btw. why this doesn't work?

        - Aleksi



Fri, 20 Dec 2002 03:00:00 GMT  
 Range.generate

Quote:
>>>>> "A" == Aleksi Niemel<iso-8859-1> writes:

A> p (3..5).generate   # btw. why this doesn't work?

 this is
      (p (3..5)).generate

 you need to write :

      p ((3..5).generate)

Guy Decoux



Fri, 20 Dec 2002 03:00:00 GMT  
 Range.generate

Quote:

> How about defining Range.generate which would return an array:

.to_a does this too...


Fri, 20 Dec 2002 03:00:00 GMT  
 Range.generate

Quote:
> A> p (3..5).generate   # btw. why this doesn't work?
>  this is
>       (p (3..5)).generate

>  you need to write :

>       p ((3..5).generate)

How come I happen to expect the dot binding the parts together before the
space. Are my expectations way off?

        - Aleksi



Fri, 20 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. problems generating a report with a date range

2. CW4 - Ranges question - changing range values while running

3. Range limits type : Range of values

4. Range#size, Range#length

5. * y for y in range(3) ] * x for x in range(2) ]

6. Open generated HTML in browser (was - Generate HTML in GUI app)

7. Locator on Browse with Range limit : 'RANGE OF VALUES'

8. exponential range

9. coding a data range (second post attempt)

10. coding a date range

11. Slider range

12. Excel activex, setting multiple cells in a column range

 

 
Powered by phpBB® Forum Software