wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 53  →  ?path2? @ 55
/Lambda/Extensions.cs
@@ -207,6 +207,22 @@
/// <param name="pass">function with no parameters and return type T in case condition passes</param>
/// <param name="fail">function with no parameters and return type T in case condition fails</param>
/// <returns>the result of pass in case condition holds or the result of fail otherwise</returns>
public static V IfElse<T, V>(this T arg, Func<T, bool> condition, Func<T, V> pass, Func<T, V> fail)
{
return condition.Invoke(arg) ? pass.Invoke(arg) : fail.Invoke(arg);
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Invokes pass if and only if condition holds or fail otherwise.
/// </summary>
/// <typeparam name="T">the return type of the pass and fail functions</typeparam>
/// <param name="condition">the branch condition</param>
/// <param name="pass">function with no parameters and return type T in case condition passes</param>
/// <param name="fail">function with no parameters and return type T in case condition fails</param>
/// <returns>the result of pass in case condition holds or the result of fail otherwise</returns>
public static T IfElse<T>(this bool condition, Func<T> pass, Func<T> fail)
{
return condition ? pass.Invoke() : fail.Invoke();