闰年

def leap? year
  (year%4 == 0) and !(year%100 == 0 and year%400 != 0)
end

puts leap? 1978 # false
puts leap? 1988 # true
puts leap? 1900 # false
puts leap? 2000 # true

编程技巧