Opt<T extends Object> typedef
Opt<T extends Object> = Option<T>
Compact alias for Option.
Option
A generic Option type that represents either a Val value or a Nil (absence of value).
Use Option to make presence and absence explicit without throwing
exceptions or hiding absence behind null.
- Val means a value is present.
- Nil means no value is present.
Tis non-nullable; Val cannot wrapnull. Use Nil to represent absence.
Example:
final option = Val<int>(42);
option.fold(
onVal: (value) => print('Value: $value'),
onNil: () => print('No value'),
);
final doubled = option.next((value) => Val(value * 2));
switch (option) {
case Val<int>(:final value):
print('Value: $value');
case Nil<int>():
print('No value');
}
Implementation
typedef Opt<T extends Object> = Option<T>;