This snippet should be in a loop I guess:
(1979...2040).each do |year|
if year % 400 == 0 or (year % 4 == 0 and (year % 100 != 0))
Before I want to start RoR I first want to start learning Ruby. So I follow this online book : http://pine.fm/LearnToProgram/?Chapter=06
But Im stuck at the leap year problem.
This is the code so far:
print "Enter beginning year : " begin_year = gets.chomp year1 = begin_year.to_i print "Enter end year : " end_year = gets.chomp year2 = end_year.to_i while year1 <= year2
if ((year1 % 4 == 0) and (year1 %100 !=0) and (year1%400 == 0) puts year1 end year1 = year1 + 1
But I do not see the leap years. I can enter the years and then the programm has no output. What did I do wrong ?