On Saturday, 8 June 2024 at 18:25:20 UTC, drug007 wrote:

~~~
    {
        const seed = castFrom!long.to!uint(Clock.currStdTime);
        auto rng = Random(seed);
auto result = generate!(() => uniform(0, 10, rng))().take(7);
        // new random numbers sequence every time
        result.writeln;
    }
}
~~~

I managed to use this piece of code and it worked.

~~~
uint seed = castFrom!long.to!uint(Clock.currStdTime);
auto rng = Random(seed);
~~~

I am not exactly sure what the exclamation points stand for in the first line of code. Probably, defining a type to class ```castFrom``` and function ```to```. But I get the idea that it just cast long to uint since ```Random``` requires an unsigned int.

I assume from this line of code that C casting like ```(uint)varname``` would not work.


Reply via email to