Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As you hopefully know, the modern C# equivalent is not bad either, especially with top level statements and implicit global usings (The following is the whole program):

    foreach (var i in Enumerable.Range(1,100))
    {
        Console.WriteLine(
            (i%3==0,i%5==0) switch
            {
                (true, true) => "FizzBuzz",
                (true, _) => "Fizz",
                (_, true) => "Buzz",
                (_, _) => $"{i}"
            }
        );
    }
This is so much nicer than what was possible back when the linked question was asked.


It gets a bit nicer still.

    (i%3,i%5) switch {
        (0, 0) => "FizzBuzz",
        (0, _) => "Fizz",
        (_, 0) => "Buzz",
        (_, _) => i
    }




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: