Zig NEWS

Discussion on: A Guessing Game

Collapse
 
plouw profile image
Louw • Edited

Thank you for the article, it's great for learning zig when used to higher level languages. I noticed a bug. When getting a Random struct before setting the range

var prng = std.rand.DefaultPrng.init(seed);
// the 'random' access here:
const rand = &prng.random;

    const target_number = rand.intRangeAtMost(u8, 1, 100);

Enter fullscreen mode Exit fullscreen mode

Throws a not accessible prop exception, it needs to be initialized, at least then it works for me.

const rand = &prng.random();
Enter fullscreen mode Exit fullscreen mode