Skip to main content

maybe

Call typ on value if val is defined.

def maybe(
typ: Callable,
val: Any
) - > Any

Call typ on value if val is defined.

Parameters

NameTypeDescription
typCallableThe constructor or transformation function to apply to the value.
valAnyThe input value to be checked for a None value before processing.

Returns

TypeDescription
AnyThe result of applying the type constructor or function to the value if it is not None; otherwise, returns None.