make it even shorter: `class year def self.leap?(y) = y % 400 == 0 || (y % 100 != 0 && y % 4 == 0) end` in ruby

To make the code even shorter, you can remove unnecessary parentheses and use a single line of code for the leap? method:

main.rb
class Year
  def self.leap?(y) = y % 400 == 0 || y % 100 != 0 && y % 4 == 0
end
80 chars
4 lines

Note that this code uses the Ruby shorthand syntax for single-line methods.

related categories

gistlibby LogSnag