Improve ergonomics of ["contains"]
expression
#5226
Labels
cross-platform 📺
Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)
Quoting @jfirebaugh:
["contains", ["get", "type"], ["literal", ["primary_link"]]]
This seems overly clunky for a very common case. @anandthakker what do you think about two forms:
["in", needle, ...], where the varargs are required to be literals
["in", needle, haystack], where haystack is an array
Of course, writing it as ["match", ["get", "type"], ["primary_link", ...], true, false] is another option, and more efficient.
And a final option I'll throw out here: we could support a 2-arity form of match, ["match", input, [literals...]], which is syntactic sugar for ["match", input, [literals...], true, false]. This would be the recommended and most efficient form for when you're checking inclusion in a set of literals. "contains" would still exist, but you'd only want to use it when the second argument is not an array literal.
The text was updated successfully, but these errors were encountered: