Created
July 7, 2014 09:49
-
-
Save hadynz/f7db6c9669b1f4520952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EvalExtension | |
{ | |
public static TResult Eval<T, TResult>(this T obj, Func<T, TResult> func) where T : class | |
{ | |
return obj.Eval(func, default(TResult)); | |
} | |
public static TResult Eval<T, TResult>(this T obj, Func<T, TResult> func, TResult defaultValue) where T : class | |
{ | |
return obj == null ? defaultValue : func(obj); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment