intersect method

InkList intersect(
  1. InkList otherList
)
Returns a new list that is the intersection of the current list with another list that's passed in - i.e. a list of the items that are shared between the two other lists. Equivalent to calling (list1 ^ list2) in ink.

Implementation

InkList intersect(InkList otherList) {
  var intersection = InkList();
  for (var kv in entries) {
    if (otherList.containsKey(kv.key)) {
      intersection[kv.key] = kv.value;
    }
  }

  return intersection;
}