also method

T also(
  1. void f(
    1. T it
    )
)

Returns this value after calling f with it.

Example

With this method, this snippet:

final message = 'Hello World';
print(message);
return message;

can be rewritten like this:

return 'Hello World'.also(print);

Implementation

T also(void Function(T it) f) {
  f(this);
  return this;
}