Is there a concise way to pattern match on a value and check if it is a member of multiple collectio...
c
Is there a concise way to pattern match on a value and check if it is a member of multiple collections? I would like to write this, but itโ€™s not valid syntax. (Adding the lists together would make sense in this example, but not in the real code).
Copy code
when (someValue) {
  in list1 && in list2 -> TODO()
}
Or do I have to write it like this?
Copy code
when {
  someValue in list1 && someValue in list2 -> TODO()
}
๐Ÿค” 1
For clarity, the real code has lots of cases where it checks membership in a bunch of collections.
And the โ€orโ€ variant would be possibe with:
Copy code
when (someValue) {
  in list1, in list2 -> TODO()
}
But I need the โ€andโ€ ๐Ÿ˜
e
โž• 1
๐Ÿ‘ 2