Created
January 7, 2017 02:19
-
-
Save bdkosher/887cd5d9a8d9a323ed235387e91347ee to your computer and use it in GitHub Desktop.
Should be part of Groovy JDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Integer, Long, BigInteger].each { clazz -> | |
clazz.metaClass.isOdd = { -> delegate % 2 == 1} | |
clazz.metaClass.isEven = { -> !delegate.isOdd()} | |
} | |
(1..10).each { n -> println "$n is odd? ${n.isOdd()}. $n is even? ${n.isEven()}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment