Created
July 14, 2012 20:16
-
-
Save SethTisue/3113182 to your computer and use it in GitHub Desktop.
extension methods in Scala 2.9 vs. 2.10
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
// BEFORE (Scala 2.9) | |
implicit def toRichLong(i: Long): MyRichLong = new MyRichLong(i) | |
class MyRichLong(i: Long) { | |
def digits: Seq[Int] = i.toString.map(_.asDigit) | |
} | |
// AFTER (Scala 2.10) | |
implicit class RichLong(i: Long) { | |
def digits: Seq[Int] = i.toString.map(_.asDigit) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment