[Issue 9339] std.random.uniform!Enum should return random enum member

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 18 10:30:48 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9339



--- Comment #15 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-18 10:30:47 PST ---
(In reply to comment #14)
> (In reply to comment #6)
> 
> > > T uniform(T)()
> > > if (is(T == enum) && isIntegral!T || isSomeChar!T)
> > > {
> > >     static immutable T[EnumMembers!T.length] members = [EnumMembers!T];
> > >     return members[std.random.uniform(0, members.length)];
> > > }
> > 
> > That's not doing what was requested.
> 
> Then I don't understand. 

I've misread the last statement (it was late) as:

return std.random.uniform(0, members.length);

instead of:

return members[std.random.uniform(0, members.length)];

Apologies.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list