when abstract method

void when({
  1. Consume<S> success = _nothing,
  2. Consume<F> failure = _nothing,
})

Calls success if this is a Success, or failure if this is a Failure.

Success('s').when(success: print); // 's'

Failure('f').when(success: print); // nothing

Implementation

void when({Consume<S> success = _nothing, Consume<F> failure = _nothing});