Frederick Cheung
8/23/2008 4:07:00 PM
On 22 Aug 2008, at 04:24, Matthew Moss wrote:
>
> I found this line in the initializer a little curious:
>
> ignored, @start_seed = srand, srand
>
> `srand` returns the previous seed. Calling it twice in a row will
> first set the seed, then return that and set it again to a new value.
> But the saved seed is what is used in calls to `next`. It's a nice
> trick to get the (time-based) seed generated by `srand`.
It's worth noting that (when available) srand with no arguments will
try and use things like /dev/random to seed itself so you can get
yourself a nice random seed.
Fred