inverse property

Iso<B, A> get inverse

Flips the direction of this isomorphism.

Returns a new Iso that transforms from B to A instead of A to B, by swapping the to and from functions. This is mathematically free since isomorphisms are symmetric.

If iso.to(a) == b, then iso.inverse.from(b) == a.

Example:

final iso = Iso(to: int.parse, from: (i) => i.toString());
final inv = iso.inverse;
assert(inv.to(30) == '30');
assert(inv.from('30') == 30);

Implementation

Iso<B, A> get inverse => Iso(to: from, from: to);