V Thu, 26 Jan 2017 06:32:10 +0000
Profile Anaysis via Digitalmars-d <[email protected]> napsáno:
> Why not make enum a comparable type to structs and classes?
>
> They are static so they can't contain any mutable fields but
> surely they can contain methods? And especially they should be
> able to contain static methods!?
>
struct EnumWithMethods
{
@disable this();
static enum Senum
{
one,
two,
three,
}
alias Senum this;
static getOne()
{
return this.one;
}
}
void main()
{
import std.stdio;
auto x = EnumWithMethods.one;
auto y = EnumWithMethods.getOne();
writeln(x);
writeln(y);
}