From: Marnen Laibow-Koser Date: 2009-12-30T02:00:42+09:00 Subject: Re: Question abour rand() Panagiotis Atmatzidis wrote: > Dear Sirs, > > I'm looking for a way to create a random sequence of numbers using the > 'rand' method. I can think of something like: > > ----- > while pipi == TRUE > if x > 1950 || x < 2000 > return x > pipi = FALSE > ------ > > Since however the book that I'm reading has not introduced while/else/if > etc. I'm thinking that there must be an easier and probably more > sensible way to approach this. As far as I've read rand(2000) will give > random numbers from 0-to-2000 no matter what Use Seebs' suggestion. > > NOTE: I don't want to use another method just to do the job. Then you are probably being silly. It will make for more readable and more reusable code if you encapsulate this in a method. Having lots of short methods is generally a *good* thing. > > thanks in advance & best regards > > > > Panagiotis (atmosx) Atmatzidis > > email: atma@convalesco.org > URL: http://www.convalesco.org > GnuPG ID: 0xFC4E8BB4 > gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xFC4E8BB4 Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.