map<B> method

  1. @override
Option<B> map<B>(
  1. B f(
    1. T t
    )
)
override

Change the value of type T to a value of type B using function f.

/// Change type `String` (`T`) to type `int` (`B`)
final Option<String> mStr = Option.of('name');
final Option<int> mInt = mStr.map((a) => a.length);

👇

[🥚].map((🥚) => 👨‍🍳(🥚)) -> [🍳]
[_].map((🥚) => 👨‍🍳(🥚)) -> [_]

Implementation

@override
Option<B> map<B>(B Function(T t) f) => Some(f(_value));