Make string in "if" condition more compact

Hi, how can I makr this “if” condition more compact:
Condition: Name=“Tom” OR Name=“Sara” OR Name = “John” OR Name = “Hanna”
I tried Name = “Tom” OR “Sara” OR “John” OR “Hanna” but that didn’t work.
Thanks

You can define a list of strings with your values ( Names: {“Tom”,“Sara”,“John”} ) and use the function contains in your if statement as such: Names.Contains(Name) that will return true if the value is found within the list.

3 Likes

you mean create a array of all the names and then check if the condition has a value from the array?

Thanks for the replies. If I have Tomaso in the array and I would use names.contains(“Tom”) wouldn’t it then be true? I would want it then to be false as Tom=!Tomaso.

Contains will check for an exact match so Tom would be different than Tomaso.

Yes that is the main idea but I suggest using a List since it has a function Contains. An array does not as far as I can remember.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.