Function enumap
Construct an
from a sequence of key/value Enumap
pairs
.
Any values not specified default to V.init
.
Prototype
auto enumap(T...)( T pairs ) @nogc if (T.length >= 2 && T.length % 2 == 0);
Example
with (Element) { auto elements = enumap(air, 1, earth, 2, water, 3); assert(elements[air] == 1); assert(elements[earth] == 2); assert(elements[water] == 3); assert(elements[fire] == 0); // unspecified values default to V.init }
Authors
Ryan Roden-Corrent (rcorre)
Copyright
© 2015, Ryan Roden-Corrent
License
MIT