operator [] method

Subject<V> operator [](
  1. K key
)

Implementation

Subject<V> operator [](K key) {
  return context.nest(
      () => prefixFirst('contains a value for ', literal(key)), (actual) {
    if (!actual.containsKey(key)) {
      return Extracted.rejection(
          which: prefixFirst('does not contain the key ', literal(key)));
    }
    return Extracted.value(actual[key] as V);
  });
}