Skip to content

Instantly share code, notes, and snippets.

@SethTisue
Created July 14, 2012 20:16
Show Gist options
  • Save SethTisue/3113182 to your computer and use it in GitHub Desktop.
Save SethTisue/3113182 to your computer and use it in GitHub Desktop.
extension methods in Scala 2.9 vs. 2.10
// 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