News for hackers. Stuff that matters.
Re:Why your first Rust FizzBuzz implementation may not work by taeric on Monday October 13, 2014 @11:16AM (#8449005)
I fail to see how a simple switch statement doesn't read just as easily. I mean, sure I have to know the mod 15 trick, but... not exactly hard.

    function fizzBuzz(i) { 
      switch(i % 15) { 
        case 0: return "fizbuzz";
        case 5: 
        case 10: return "buzz";
        case 3:
        case 6:
        case 9:
        case 12: return "fizz";
        default: return i.toString();
      }
    }
    [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map(fizzBuzz)
Re:Why your first Rust FizzBuzz implementation may not work by chrismorgan on Monday October 13, 2014 @11:19AM (#8449023)
Even that is better in Rust (using the enum from the end):

    match i % 15 {
        0 => FizzBuzz,
        5 | 10 => Buzz,
        3 | 6 | 9 | 12 => Fizz,
        _ => Number(i),
    }
Re:Why your first Rust FizzBuzz implementation may not work by taeric on Monday October 13, 2014 @11:27AM (#8449065)
I actually agree it is better. But... my point was that the switch statement was already pretty readable. If there are gains, they feel pretty small in these examples.

And to be clear, I like pattern matching. A lot. I just don't feel this really shows it off that well.

Re:Why your first Rust FizzBuzz implementation may not work by icedog on Monday October 13, 2014 @11:46AM (#8449162)
What do you expect; it's FizzBuzz.
Re:Why your first Rust FizzBuzz implementation may not work by mattmanser on Monday October 13, 2014 @11:46AM (#8449166)
Only because you're expecting the cases to fall through, you're being blinded by your own expectation.

Your code is considered bad practice in many languages.