ResultExtensionsOkIfT(Boolean, T, String) Method

Creates a result of T as Ok variant with value value if the okCondition holds. Otherwise, it will map into an Err.
C#
Shape shape = GetShape(); // valid only if shape has a positive base area.
Res<Shape> resultShape = OkIf(shape.GetBaseArea() > 0, shape);

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public static Res<T> OkIf<T>(
	bool okCondition,
	T value,
	string strOkCondition = ""
)

Parameters

okCondition  Boolean
Condition that must hold for the return value to be Ok(value).
value  T
Underlying value of the Ok variant to be returned if okCondition holds.
strOkCondition  String  (Optional)
Name of the condition; to be appended to the error message if it does not hold. Omitting the argument will automatically be filled with the condition's expression in the caller side.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Result.ResultExtensions.OkIf``1(System.Boolean,``0,System.String)"]

Return Value

ResT

See Also