2012-08-13から1日間の記事一覧
Ruby だとこういうやり方もありなのかなー。 [ソース] class Integer def fizz? !fizzbuzz? && self % 3 == 0 end def buzz? !fizzbuzz? && self % 5 == 0 end def fizzbuzz? self % 15 == 0 end end 1.upto 30 do |n| puts n.fizz? ? "Fizz" : n.buzz? ? "B…
Ruby だとこういうやり方もありなのかなー。 [ソース] class Integer def fizz? !fizzbuzz? && self % 3 == 0 end def buzz? !fizzbuzz? && self % 5 == 0 end def fizzbuzz? self % 15 == 0 end end 1.upto 30 do |n| puts n.fizz? ? "Fizz" : n.buzz? ? "B…