[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Fwd: Please Forward: Ruby Quiz Submission

James Gray

6/3/2007 5:04:00 PM

Begin forwarded message:

> From: David Patterson <bob0the0mighty@cox.net>
> Date: June 1, 2007 8:22:59 AM CDT
> To: submission@rubyquiz.com
> Subject: Please Forward: Ruby Quiz Submission
>
> I've been following Ruby Quiz for the last few months, but this is my
> first submission.
>
> This is my hand written code:
> (1..100).each {|x|
> temp += (x%3==0) ? "Fizz" : ""
> temp += (x%5==0) ? "Buzz" : ""
> puts (temp.size==0) ? x : temp
> }
>
> this didn't run because temp is Nil, which gets me sometimes.
> Quick fix to:
> (1..100).each {|x|
> temp = (x%3==0) ? "Fizz" : ""
> temp += (x%5==0) ? "Buzz" : ""
> puts (temp.size==0) ? x : temp
> }
> and it ran fine. I wonder how bad this sort of error would be.
> Thanks
> for the quizzes!
>
> David Patterson