Created
October 2, 2019 19:25
-
-
Save fjod/b61698c1d6c345f63b92076e78c3fd9e to your computer and use it in GitHub Desktop.
C# 8 switch with true
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
return true switch | |
{ | |
_ when a == b => 1, | |
_ when foo == "foobar" => 2, | |
_ when someFunction() => 3, | |
_ => 4, | |
}; | |
https://www.reddit.com/r/csharp/comments/dccpx9/using_pattern_matching_to_replace_lengthy_ifelse/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment