Comment

Comment by qyv

Ruby the Ruby way:

  module FizzBuzz
    def to_fb
      s = ''
      s << (self % 3 == 0 ? 'Fizz' : '')
      s << (self % 5 == 0 ? 'Buzz' : '')
      s << self.to_s if s.empty?
      return s
    end
  end

  Integer.include(FizzBuzz)

  1.upto(100) { |i| puts i.to_fb }
parent qyv 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton