id<T> function

T id<T>(
  1. T a
)

Returns the given a.

Same as identity.

Shortcut function to return the input parameter:

final either = Either<String, int>.of(10);

/// Without using `identity`, you must write a function to return
/// the input parameter `(l) => l`.
final noId = either.match((l) => l, (r) => '$r');

/// Using `identity`/`id`, the function just returns its input parameter.
final withIdentity = either.match(identity, (r) => '$r');
final withId = either.match(id, (r) => '$r');

Implementation

T id<T>(T a) => a;