wasSharp – Diff between revs 53 and 55

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 53 Rev 55
Line 205... Line 205...
205 /// <typeparam name="T">the return type of the pass and fail functions</typeparam> 205 /// <typeparam name="T">the return type of the pass and fail functions</typeparam>
206 /// <param name="condition">the branch condition</param> 206 /// <param name="condition">the branch condition</param>
207 /// <param name="pass">function with no parameters and return type T in case condition passes</param> 207 /// <param name="pass">function with no parameters and return type T in case condition passes</param>
208 /// <param name="fail">function with no parameters and return type T in case condition fails</param> 208 /// <param name="fail">function with no parameters and return type T in case condition fails</param>
209 /// <returns>the result of pass in case condition holds or the result of fail otherwise</returns> 209 /// <returns>the result of pass in case condition holds or the result of fail otherwise</returns>
-   210 public static V IfElse<T, V>(this T arg, Func<T, bool> condition, Func<T, V> pass, Func<T, V> fail)
-   211 {
-   212 return condition.Invoke(arg) ? pass.Invoke(arg) : fail.Invoke(arg);
-   213 }
-   214  
-   215 ///////////////////////////////////////////////////////////////////////////
-   216 // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
-   217 ///////////////////////////////////////////////////////////////////////////
-   218 /// <summary>
-   219 /// Invokes pass if and only if condition holds or fail otherwise.
-   220 /// </summary>
-   221 /// <typeparam name="T">the return type of the pass and fail functions</typeparam>
-   222 /// <param name="condition">the branch condition</param>
-   223 /// <param name="pass">function with no parameters and return type T in case condition passes</param>
-   224 /// <param name="fail">function with no parameters and return type T in case condition fails</param>
-   225 /// <returns>the result of pass in case condition holds or the result of fail otherwise</returns>
210 public static T IfElse<T>(this bool condition, Func<T> pass, Func<T> fail) 226 public static T IfElse<T>(this bool condition, Func<T> pass, Func<T> fail)
211 { 227 {
212 return condition ? pass.Invoke() : fail.Invoke(); 228 return condition ? pass.Invoke() : fail.Invoke();
213 } 229 }