Bug 5883 – std.random.dice() without rnd generator

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-04-24T14:25:00Z
Last change time
2011-04-24T16:11:30Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-04-24T14:25:38Z
This is the online documentation of std.random.dice() (DMD 2.052) (note the missing rnd generator agument): http://www.digitalmars.com/d/2.0/phobos/std_random.html#dice auto x = dice(0.5, 0.5); // x is 0 or 1 in equal proportions auto y = dice(50, 50); // y is 0 or 1 in equal proportions auto z = dice(70, 20, 10); // z is 0 70% of the time, 1 30% of the time, // and 2 10% of the time But this generates several compile bugs: import std.random; void main() { dice(0.5, 0.5); } While this compiles and runs: import std.random; void main() { auto rnd = Xorshift(1); dice(rnd, 0.5, 0.5); } This looks like a documentation bug, but I prefer to see it as an enhancement request. See also issue 5849
Comment #1 by dsimcha — 2011-04-24T16:11:30Z
This was fixed a while back in Git and will be in the next release. (Thanks, Andrei.) https://github.com/D-Programming-Language/phobos/commit/1083bd4e7b4ef0475084d7eab2e67c65e511c3d4