gistlib
To make the code even shorter, you can remove unnecessary parentheses and use a single line of code for the leap? method:
leap?
main.rbclass Year def self.leap?(y) = y % 400 == 0 || y % 100 != 0 && y % 4 == 0 end 80 chars4 lines
class Year def self.leap?(y) = y % 400 == 0 || y % 100 != 0 && y % 4 == 0 end
Note that this code uses the Ruby shorthand syntax for single-line methods.
gistlibby LogSnag