Skip to content

Instantly share code, notes, and snippets.

@johansson
Created March 27, 2013 02:58
Show Gist options
  • Save johansson/5251234 to your computer and use it in GitHub Desktop.
Save johansson/5251234 to your computer and use it in GitHub Desktop.
FizzBuzz using the PatternMatching's Fluent API.
foreach (var i in Enumerable.Range(1, 100))
i.With(x => x % 3 == 0).Do(_ => Console.WriteLine("Fizz"))
.With(x => x % 5 == 0).Do(_ => Console.WriteLine("Buzz"))
.With(x => x % 3 != 0 && x % 5 != 0).Do(Console.WriteLine);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment