uniform

Returns a uniformly selected member of enum E. If no random number generator is passed, uses the default rndGen.

Examples

enum Fruit { Apple = 12, Mango = 29, Pear = 72 }
foreach (immutable _; 0 .. 100)
{
    foreach (immutable f; [uniform!Fruit(), rndGen.uniform!Fruit()])
    {
        assert(f == Fruit.Apple || f == Fruit.Mango || f == Fruit.Pear);
    }
}

Meta