Created
November 1, 2022 14:38
-
-
Save dyguests/2511bd527e1a2cb3d32c239fd7bd732a to your computer and use it in GitHub Desktop.
ObjectEx, Let, Also, C#
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
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