Created
May 25, 2011 16:37
-
-
Save kmizu/991315 to your computer and use it in GitHub Desktop.
overloading in package object
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
import foo._ | |
object A { | |
def main(args: Array[String]) { | |
println(plus(1)) | |
println(plus(1, 3)) | |
} | |
} | |
//scalac package.scala | |
//scalac A.scala | |
//scala A |
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
package object foo { | |
def plus(x: Int):Int = x + 1 | |
def plus(x: Int, inc: Int):Int = x + inc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment