Class BoolExtensions
Provides extension methods for boolean values.
Inherited Members
Namespace: RustyOptions
Assembly: RustyOptions.dll
Syntax
public static class BoolExtensions
Methods
| Edit this page View SourceThenSome<T>(bool, T)
Creates an Option<T> with a value if the boolean condition is true, otherwise returns the default value.
Declaration
public static Option<T> ThenSome<T>(this bool self, T value) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
bool | self | The boolean condition. |
T | value | The value to be wrapped in the option. |
Returns
Type | Description |
---|---|
Option<T> | An Option<T> with the specified value if the condition is true, otherwise the default value. |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
Then<T>(bool, Func<T>)
Executes a function if the boolean value is true and returns an option.
Declaration
public static Option<T> Then<T>(this bool self, Func<T> thenFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
bool | self | The boolean value. |
Func<T> | thenFunc | The function to execute if the boolean value is true. |
Returns
Type | Description |
---|---|
Option<T> | An option containing the result of the function if the boolean value is true, otherwise the default option value. |
Type Parameters
Name | Description |
---|---|
T | The type of the option value. |