Created
January 8, 2013 20:56
-
-
Save mmorearty/4487832 to your computer and use it in GitHub Desktop.
I can't get the new Scala 2.10 implicit value classes to compile. Trying to compile this with "scalac TestImplicitValue.scala" fails with the errors shown below in the Comments section. If you reply, please let me know on Twitter: @mmorearty
This file contains 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
implicit class MyRichInt(val self: Int) extends AnyVal { | |
def plusOne: Int = self + 1 | |
} | |
object TestImplicitValue { | |
def main(args: Array[String]) = | |
println(30.plusOne) | |
} |
Author
mmorearty
commented
Jan 8, 2013
$ scalac -version
Scala compiler version 2.10.0 -- Copyright 2002-2012, LAMP/EPFL
Hi Mike! I think this is just a scope issue. Try:
object TestImplicitValue extends App {
implicit class MyRichInt(val self: Int) extends AnyVal {
def plusOne: Int = self + 1
}
println(30.plusOne)
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment