Reputation: 3150
In many functional programming languages there is a way to do pattern matching, like F# has match expression with
.
In my use case, I'd like to match a string to a set of strings/regexes and returning a value(a string):
// path:string
iif(path == '/', 'home',
iif(path == '/search', 'search',
iif(path == '/*/*/*-for-sale-*', 'product',
'other',
)))
The iif
syntax is really ugly though. Is there a more concise way to find a string match and return a value?
Upvotes: 1
Views: 77
Reputation: 743
There is a relatively new syntax for case():
range Size from 1 to 15 step 2
| extend bucket = case(Size <= 3, "Small",
Size <= 10, "Medium",
"Large")
Upvotes: 1