Extend 'in' operator to check for array subset.
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 19h 14m
- Merged PRs (30d)
- 63
Description
Currently, the `in` operator does the following for `a in b` example:
* if `b` is a string, it checks if `a` is a substring of `b`
* if `b` is a list, it checks if `a` is an element of `b`
I propose that we extend the `in` operator to have the following additional behavior:
* if `b` is a list, and `a` is a list, then `a in b` should check if `a` is a subset of the elements in `b`
Examples:
* `["a", "b"] in ["a", "b", "c"]` == true
* `["a", "d"] in ["a", "b", "c"]` == false
The same goes for field references. Let's suppose the `[tags]` field is `["web", "frontend", "newyork", "staging"]`, then the following:
* `["web", "frontend"] in [tags]` == true
* `["db", "newyork"] in [tags]` == false
General idea is to have `in` act as a [subset](https://en.wikipedia.org/wiki/Subset) check if both operands are list values (array literals, fieldreferences that have array values, etc)
Contributor guide
Assessment
This issue has not been assessed yet.