identity< T> function
T
identity< T>(
- T a
Returns the given a
.
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`, the function just returns its input parameter.
final withIdentity = either.match(identity, (r) => '$r');
Implementation
T identity<T>(T a) => a;