Skip to content

Instantly share code, notes, and snippets.

@dyguests
Created November 1, 2022 14:38
Show Gist options
  • Save dyguests/2511bd527e1a2cb3d32c239fd7bd732a to your computer and use it in GitHub Desktop.
Save dyguests/2511bd527e1a2cb3d32c239fd7bd732a to your computer and use it in GitHub Desktop.
ObjectEx, Let, Also, C#
namespace Plugins.FanhlCores.Scripts.Tools
{
public static class ObjectEx
{
// Kotlin: fun <T, R> T.let(block: (T) -> R): R
public static R Let<T, R>(this T self, Func<T, R> block)
{
return block(self);
}
// Kotlin: fun <T> T.also(block: (T) -> Unit): T
public static T Also<T>(this T self, Action<T> block)
{
block(self);
return self;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment