hasType

Tests if the algebraic type stores a value of a certain data type.

  1. bool hasType(TaggedAlgebraic!U ta)
    bool
    hasType
    (
    T
    U
    )
    ()
  2. bool hasType(TaggedAlgebraic!U ta)

Examples

union Fields {
	int number;
	string text;
}

TaggedAlgebraic!Fields ta = "test";

assert(ta.hasType!string);
assert(!ta.hasType!int);

ta = 42;
assert(ta.hasType!int);
assert(!ta.hasType!string);

Meta