Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/814#discussion_r147567984 --- Diff: metron-stellar/stellar-common/README.md --- @@ -100,6 +102,28 @@ In the core language functions, we support basic functional programming primitiv * `FILTER` - Filters a list by a predicate in the form of a lambda expression. For instance `FILTER([ 'foo', 'bar'], (x ) -> x == 'foo' )` returns `[ 'foo' ]` * `REDUCE` - Applies a function over a list of input. For instance `REDUCE([ 1, 2, 3], (sum, x) -> sum + x, 0 )` returns `6` +### Stellar Language Match Expression + +Stellar provides the capability to write match expressions, which are similar to switch statements commonly found in c like languages, but more like +Scala's match. + +The syntax is: +* `match{ logical_expression1 : evaluation expression1, logical_expression2 : evaluation_expression2` : A match expression with no default +* `match{ logical_expression1 : evaluation expression1, logical_expression2 : evaluation_expression2, default : default_expression}` : A match expression with a default expression + +Where: + +* `logical_expression` is a Stellar expression that evaluates to true or false. For instance `var > 0` or `var > 0 AND var2 == 'foo'` --- End diff -- ```bash Please note that functions are loading lazily in the background and will be unavailable until loaded fully. [Stellar]>>> Functions loaded, you may refer to functions now... [Stellar]>>> foo := 500 [Stellar]>>> match{ foo < 100 : THROW('oops'), foo > 200 : 'ok', default : THROW('exception thrown') } ok [Stellar]>>> ``` I don't see that. Also, if you check the last test in TestMatch you will see I have a test for this kind of thing.
---