tee Functions
These functions allow us to execute side effects based on our option. They are useful for logging and other side effects that we want to execute without changing the option.
Consider the following code for the examples below
teeSome
If the option is Some, executes the function on the Some value. Passes through the input value unchanged.
Function Signature
Examples
Example 1
teeNone
If the option is None, executes the function. Passes through the input value unchanged.
Function Signature
Examples
Example 1
teeIf
If the option is Some and the predicate returns true for the wrapped value, executes the function on the Some value. Passes through the input value unchanged.
Function Signature
Examples
Example 1
Example 2
Last updated