src/main/scala/leap.scala

1
2
3
4
5
6
7
8
9
10
11
object Year {
  def apply(year: Int) = new Year(year)
}

class Year(year: Int) {
  def isLeap = {
    def dividesBy(n: Int) = year % n == 0

    dividesBy(4) && (!dividesBy(100) || dividesBy(400))
  }
}

@abo64 thinks this looks great

Comments

Simpler boolean operation. There are probably better opportunities for me to use match ;)

helenst commented 13 April 2016 at 16:00 UTC

You're not logged in right now. Please login via GitHub to comment