Use this function when you have a value and you want to test it against a pattern.
strike will iterate through your Matchers and use the first match's Transformer to map val to a TOut.
val
TOut
strike is comparable to the match operator in Rust, F#, and other languages with idiomatic Pattern Matching.
match
{@link pattern}
1.0.0
enum Coin { Quarter, Nickel, } function getValue(coin: Coin): number { return strike(coin, match(Coin.Quarter, 0.25), match(Coin.Nickel, 0.05), otherwise(0) ); } assertEq(getValue(Coin.Quarter), 0.25); assertEq(getValue(Coin.Nickel), 0.05);
Generated using TypeDoc
Use this function when you have a value and you want to test it against a pattern.
strike will iterate through your Matchers and use the first match's Transformer to map
val
to aTOut
.strike is comparable to the
match
operator in Rust, F#, and other languages with idiomatic Pattern Matching.{@link pattern}
1.0.0
enum Coin { Quarter, Nickel, } function getValue(coin: Coin): number { return strike(coin, match(Coin.Quarter, 0.25), match(Coin.Nickel, 0.05), otherwise(0) ); } assertEq(getValue(Coin.Quarter), 0.25); assertEq(getValue(Coin.Nickel), 0.05);