News for hackers. Stuff that matters.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by waffle_ss on Thursday January 19, 2012 @12:34PM (#3485535)
This is my conclusion as well. To wit, an approximate translation of his method into Ruby:

  fizzbuzz = (1..100).to_a.map do |i|
    result = "" # 1:23 initialize a variable
    result += "Fizz" if i % 3 == 0
    result += "Buzz" if i % 5 == 0
    result = i.to_s if result.nil?
    result
  end
The corrected solution would be to change `result.nil?` to `result.empty?`, i.e. checking for "empty string" instead of "null".

There are no comments on this comment yet.