February 13, 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.
February 13, 2014
It would be useful if someone added this as an example to the docs, so that beginners don't end up in the same situation as me in the future.
February 13, 2014
On 2/13/14, Anton <vizardx@gmail.com> wrote:
> It would be useful if someone added this as an example to the docs, so that beginners don't end up in the same situation as me in the future.

My mistake for not adding an example when implementing the function. Here we go:

https://github.com/D-Programming-Language/phobos/pull/1932
1 2
Next ›   Last »