----- Original Message ----- From: "Orion Hunter" <orion2480 / hotmail.com> To: "ruby-talk ML" <ruby-talk / ruby-lang.org> Sent: Tuesday, July 29, 2003 3:07 PM Subject: Re: Generating random numbers? > >For example, this code (untested) I would expect > >to produce such repetition: > > > > 100.times do > > Kernel.srand(Time.now.usec) > > puts rand(100) > > end > > I completely understand why this would result in sequentially repeated > numbers. However, that is not what my code did... rather it called > Kernel.srand( Time.now.usec ) once in a completely unrelated function > (unrelated, but it was indeed called before the other function which was > giving me the duplicates). > > If I ever figure out why, I'll post it here. My guess would be that it was some kind of logic bug and your function was actually getting called repeatedly. But as Matz said, you don't need srand at all unless you want to reproduce a specific sequence. Hal -- Hal Fulton hal9000 / hypermetrics.com