Skip to content

Instantly share code, notes, and snippets.

@brianmed
Last active August 14, 2021 01:01
Show Gist options
  • Save brianmed/06d0788b4add8cabac8192e907ef0d82 to your computer and use it in GitHub Desktop.
Save brianmed/06d0788b4add8cabac8192e907ef0d82 to your computer and use it in GitHub Desktop.
Fun code in C# 10 (top level program) that coalesces booleans
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