On Fri, Jan 21, 2022 at 10:12:42AM +0000, forkit via Digitalmars-d-learn wrote: [...] > Random rnd; > static this() { rnd = Random(unpredictableSeed); } // thanks Ali
Actually you don't even need to do this, unless you want precise control over the initialization of your RNG. If you don't specify the RNG parameter in the calls to std.random functions, they will use the default RNG, which is already initialized with unpredictableSeed. [...] > // id needs to be 9 digits, and needs to start with 999 > int[] idArray = takeExactly(iota(999*10^^6, 10^^9), > recordsNeeded).array; [...] This is wasteful if you're not planning to use every ID in this million-entry long array. Much better to just use an AA to keep track of which IDs have already been generated instead. Of course, if you plan to use most of the array, then the AA may wind up using more memory than the array. So it depends on your use case. T -- Never wrestle a pig. You both get covered in mud, and the pig likes it.