Enumap.this - multiple declarations

Function Enumap.this

Construct an Enumap from a static array.

Prototype

this(
  V[length] values
);

Example

auto elements = Enumap!(Element, int)([1, 2, 3, 4]);

assert(elements[Element.air]   == 1);
assert(elements[Element.earth] == 2);
assert(elements[Element.water] == 3);
assert(elements[Element.fire]  == 4);

Template Enumap.this

Assign from a range with a number of elements exactly matching length.

Arguments

template this(R);

Functions

Function name Description
this

Example

import std.range : repeat;
Enumap!(Element, int) elements = 9.repeat(4);
assert(elements.air   == 9);
assert(elements.earth == 9);
assert(elements.water == 9);
assert(elements.fire  == 9);

Authors

Ryan Roden-Corrent (rcorre)

Copyright

© 2015, Ryan Roden-Corrent

License

MIT