From: Hh Rg on 23 Jun 2010 16:19 The problem comes from a beginnerĀ“s tutorial. Using methods like .leap? of course work just fine. However, a beginner is not familiar with them. This a way to do it using the tools showed in the same tutorial up to that level: puts "Give me the two years" year1 = gets.chomp.to_i year2 = gets.chomp.to_i puts "This is the list of years:" if year1 > year2 puts "The second year has to be bigger than the first" else while (year1 <= year2) if (((year1 % 4 == 0) and (year1 %100 !=0)) or (year1 % 400 == 0)) puts year1.to_s end (year1 = year1.to_i + 1) end puts "Finished" end -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: rake-compiler fails on Fedora 13 Next: marshalled data in 1.9 |