In
The in
operator check if the left-hand value side is in the Array and Collections, Set or Flags Enum on the right, and returns true
or false
var x: set of Color;
...
if Color.Red in x then
...
For Set and Flags Enum types, the operartor directly checks whether the value is included. For Flags, that is the equivalent of applying the and
bitwise operator and checking for equality.
For Arrays, Collections and Sequences, the in
operator invokes the LINQ Contains
method, if available.
Not In
For ease of readability, the in
operatore can be combined with not
, to negate the result.
if Color.Red not in x then
...
Which is more naturally readable than the equivalent:
if not (Color.Red in x) then
...