0 votes
by (2.4k points)

Hello there. 

Is it possible to have a <<case>> that would check if something isn't in the variable / array we make it check ?

Like... 

<<set $test to "pop">> 

<<switch $test>>

<<case neq "pap">>

What's inside isn't pap! 

<</switch>>

 

Here it's pretty useless, but I'd like to use it to check what's not into my array $seen...

Thanks a lot !

1 Answer

0 votes
by (159k points)

The correct way to test that a specific value isn't contained within an Array is...

<<set $list to ["one", "two"]>>

<<if not $list.includes("three")>>There is no "three" in the array.<</if>>


The <<switch>> macro is designed to determine if the single value passed as an argument to it is equal to one of a set of specific values. (the values passed to each of the related <<case>> macros)

by (44.7k points)

Greyelf's answer is the correct answer, but I should mention you can use <<default>> in a <<switch>> macro to cover cases not covered by your other <<case>> statements.  See the <<switch>> macro documentation for details.

...