[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03760] Range.generate

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-03 10:23:09 UTC
List: ruby-talk #3760
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

In This Thread

Prev Next