Having an enum like
enum MyEnum {
Foo(a:String);
Bar(a:String);
}
And an array like:
var elems = [
MyEnum.Foo("foo"),
MyEnum.Bar("bar")
];
what is the most compact way to check if an element type MyEnum.Foo
is in the list.
I came up with:
var containsFoo = [for (e in elems) if (switch(e) { case Foo(_): true; default: false;}) e].length > 0;
but it feels to verbose.