Union2<X1, X2> extension type

Emulate the union of the types X1 and X2.

on

Constructors

Union2.in1(X1 value)
Create a Union2 value from the first type argument.
Union2.in2(X2 value)
Create a Union2 value from the second type argument.

Properties

as1 → X1
Return the value if it has type X1, otherwise throw.
no setter
as1OrNull → X1?
Return the value if it has type X1, otherwise null.
no setter
as2 → X2
Return the value if it has type X2, otherwise throw.
no setter
as2OrNull → X2?
Return the value if it has type X2, otherwise null.
no setter
is1 bool
Return type iff the value has type X1.
no setter
is2 bool
Return type iff the value has type X2.
no setter
isValid bool
Return true iff this Union2 has type X1 or X2.
no setter
value Object?
final

Methods

split<R>(R on1(X1), R on2(X2)) → R
splitNamed<R>({R on1(X1)?, R on2(X2)?, R onOther(Object?)?, R onInvalid(Object?)?}) → R?