On 01/25/2012 04:25 AM, C wrote:
I want to fill a ubyte array with random data.
The code compiles with no warnings or errors.

Source snippet:

         auto prng = Random(unpredictableSeed);
         ubyte[] chunk;

         chunk.length = 1024;

         fill(chunk, uniform!("[]")('\x00', '\xFF', prng));

Error (at runtime):

object.Exception@c:\dmd2\windows\bin\..\..\src\phobos\std\random.d(971):
std.random.uniform(): invalid bounding interval [ , �]
----------------
423C50
423AC7
404EA8
404EEC
404AE3
4A6109
----------------

Also I lost the URL for this forum, all I see is this nasty PHP News Reader
interface.
Thank you.

The code wouldn't do what you intended even if it compiled. Use this:

auto chunk = new ubyte[1024];
foreach(ref x; chunk) x = uniform!"[]"(ubyte.min, ubyte.max);

Reply via email to