partition method

MapOptionPartition<K, V> partition()

Partitions the map into a record containing two maps: one for Some values and one for None values.

Implementation

MapOptionPartition<K, V> partition() {
  final someParts = <K, V>{};
  final noneKeys = <K>[];
  for (final entry in entries) {
    switch (entry.value) {
      case Some(value: final v):
        someParts[entry.key] = v;
      case None():
        noneKeys.add(entry.key);
    }
  }
  return (someParts: someParts, noneKeys: noneKeys);
}