std.random.uniform for enums
Anton
vizardx at gmail.com
Wed Feb 12 20:29:52 PST 2014
On Thursday, 13 February 2014 at 02:59:01 UTC, Adam D. Ruppe
wrote:
> On Thursday, 13 February 2014 at 02:52:44 UTC, Anton wrote:
>> I guess I'm mostly confused because the description for one of
>> the templates of std.random.uniform says "Returns a uniformly
>> selected member of enum E.
>
> Oooh, I didn't know it had one of those, the documentation can
> be so hard to read sometimes.
>
> Try this then:
>
> auto randomAnimal = uniform!Animals();
>
>
> The enum E there is a compile time argument, so you need the !
> in there to pass them. (uniform(Animal) would be trying to send
> it as a run time argument which doesn't work for types)
Yeah, the docs aren't the easiest to read, especially coming from
Python.
But thanks a lot for your help. Using ! does the trick.
More information about the Digitalmars-d-learn
mailing list