maybeMap<TResult extends Object?> method
- @optionalTypeArgs
- TResult str(
- PyArgument_Str value
- TResult int(
- PyArgument_Int value
- TResult float(
- PyArgument_Float value
- TResult bool(
- PyArgument_Bool value
- TResult listStr(
- PyArgument_ListStr value
- TResult listInt(
- PyArgument_ListInt value
- required TResult orElse(),
A variant of map that fallback to returning orElse.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(PyArgument_Str value)? str,
TResult Function(PyArgument_Int value)? int,
TResult Function(PyArgument_Float value)? float,
TResult Function(PyArgument_Bool value)? bool,
TResult Function(PyArgument_ListStr value)? listStr,
TResult Function(PyArgument_ListInt value)? listInt,
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case PyArgument_Str() when str != null:
return str(_that);
case PyArgument_Int() when int != null:
return int(_that);
case PyArgument_Float() when float != null:
return float(_that);
case PyArgument_Bool() when bool != null:
return bool(_that);
case PyArgument_ListStr() when listStr != null:
return listStr(_that);
case PyArgument_ListInt() when listInt != null:
return listInt(_that);
case _:
return orElse();
}
}