[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [QUIZ] FizzBuzz (#126

I. P.

6/3/2007 1:08:00 PM

|Ruby Quiz|

Everything is supposed to be a "FizzBuzz" unless having been declared
something other.

----
def fizzbuzz(value)
result = "FizzBuzz"
result.gsub!("Buzz", "") if value % 5 != 0
result.gsub!("Fizz", "") if value % 3 != 0
result = value if result.empty?
result
end

(1..100).each {|x| puts fizzbuzz(x)}
----

--
I. P. 2007-06-03T17:06