Last active
August 14, 2021 01:01
-
-
Save brianmed/06d0788b4add8cabac8192e907ef0d82 to your computer and use it in GitHub Desktop.
Fun code in C# 10 (top level program) that coalesces booleans
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
if (Coalesce(true, false) is true) { | |
Console.WriteLine("Yay!"); | |
} | |
if (Coalesce(true, true) is true) { | |
Console.WriteLine("Worked"); | |
} | |
static bool Coalesce(params bool[] truth) | |
{ | |
foreach (bool b in truth) | |
{ | |
if (b is false) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment