Getting enum from value

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 5 08:42:53 PDT 2017


On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
> Any ideas?

You can use to! in std.conv:


import std.stdio;
import std.conv;

enum Foo
{
	A = "A",
	B = "B"
}

void main()
{
	writeln("A".to!Foo);	
}


More information about the Digitalmars-d-learn mailing list