map<A, B> function

Identity<B> Function(Identity<A>) map<A, B>(
  1. B f(
    1. A
    )
)

Transforms the value inside an Identity using a given function.

The map function applies a function to the encapsulated value inside an Identity and wraps the result back into a new Identity.

Example:

final id = Identity(5);
final result = map<int, int>((x) => x * 2)(id);
print(result.value); // Outputs: 10

Implementation

Identity<B> Function(Identity<A>) map<A, B>(B Function(A) f) =>
    (Identity<A> m) => Identity<B>(f(m.value));