-
-
Save dimitris-papadimitriou-chr/0b52466ffb50164b3a2b5d06e111aebe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| int? shape = null; | |
| Shape shape = null; | |
| Shape shape = new Rectangle | |
| { | |
| Width = 100, | |
| Height = 100, | |
| }; | |
| //this is valid for all the above | |
| var t = shape.Map(x => x.ToString()); | |
| public static class FunctionalExt | |
| { | |
| public static T1 Map<T, T1>(this T @this, Func<T, T1> f) => | |
| @this switch | |
| { | |
| T value => f(value), | |
| null => default, | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment