Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How to write Else part in Pick & Match function and why Pick & Match is better than Nested if statement?
Using pick'n match will be faster as it will only evaluate your match expression once, in nestled if statements it will be evaluated once per if statement.
It is can also be a more condense way of writing your code. It is also easier to increase / decrease the values to compare .
As a no match pick() will retun zero, I often add a +1 to my pick() in order to get a default value.
Pick(1+match(...),'default value', 'value1','value2',...)
I use the following technique:
pick(WildMatch('$(vAppStreamName)','unpublished','*test*') + 1, your_else_part, value1, value2)
"Using pick'n match will be faster as it will only evaluate your match expression once, in nestled if statements it will be evaluated once per if statement."
I disagree. Last time I tested, every pick() option is evaluated, just as every branch of an if() is evaluated. Did something change or do you have experience to the contrary?
-Rob
This has been my believed known truth for years, so I have not questioned it.
Based on what you are writing here I will withdraw my statement of pick and match being faster, I do however in most cases find it faster to write script using that technique;-)
I interpret your comment as you have found the two to be about equal in term of reload performance. Is that a correct understanding?
Thanks for remarking on my comment.
@Vegar I have not tested performance in a reload script. I have however tested in a chart (confirmed yesterday). I've found the performance to be identical.
-Rob