Zig NEWS

Discussion on: How to use the random number generator in Zig

Collapse
 
kristoff profile image
Loris Cro

Thank you for the post. It's also worth pointing out that interfaces are about to change and in master branch Random has already changed. Before you would grab a pointer to the random field inside your specific implementation, while now random has become a function that you call to get the random interface.

var rand_impl = std.rand.DefaultPrng.init(42);
const num = rand_impl.random().int(i32);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
gowind profile image
Govind

Yes, I read the source code. Will update the example.