also method

T also(
  1. void block(
    1. T value
    )
)

Executes a side effect block and returns this value unchanged.

If block throws, the exception propagates and this value is not returned.

Example:

final number = 30
  .also((n) => print('Value is: $n'));
// Prints: Value is: 30
// number is still 30

Implementation

T also(void Function(T value) block) {
  block(this);

  return this;
}