Skip to content

Instantly share code, notes, and snippets.

@twogood
Last active May 4, 2020 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twogood/77e8f705d76554d6136039e7a52cc659 to your computer and use it in GitHub Desktop.
Save twogood/77e8f705d76554d6136039e7a52cc659 to your computer and use it in GitHub Desktop.
Kotlin Scope Functions (Also, Let, Run) in C# .NET Core
public static class ScopeFunctions
{
public static T Also<T>(this T self, Action<T> action)
{
action(self);
return self;
}
public static TResult Let<T, TResult>(this T self, Func<T, TResult> func) => func(self);
public static TResult Run<TResult>(Func<TResult> func) => func();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment