On 03/18/2014 01:40 PM, Eric wrote:

> Apparently you can't pass an enum as a reference,

It is possible as seen in the following code.

> I have read on this forum that someday enums may be able to be
> made with class elements.

Someday is today! :)

class C
{
    int i;

    this(int i)
    {
        this.i = i;
    }
}

enum E : C
{
    one = new C(1),
    two = new C(2)
}

void foo(ref E e)
{
    e = E.two;
}

void main()
{
    auto e = E.one;
    foo(e);
    assert(e == E.two);
}

Ali

Reply via email to