Check whether a given value is a member value of an enum.
Time complexity: O(1) if Enum has been seen before. Otherwise, O(n) where n is the number of enum values.
Enum
Space complexity: O(1) if Enum has been seen before. Otherwise, O(n) where n is the number of unique enum values.
The enum to use as the source of member values
The value to check
Whether value is a member value of Enum
value
enum Enum { A, B,}enumHas(Enum, 0); // trueenumHas(Enum, 2); // false Copy
enum Enum { A, B,}enumHas(Enum, 0); // trueenumHas(Enum, 2); // false
Check whether a given value is a member value of an enum.
Time complexity: O(1) if
Enum
has been seen before. Otherwise, O(n) where n is the number of enum values.Space complexity: O(1) if
Enum
has been seen before. Otherwise, O(n) where n is the number of unique enum values.