Created
August 3, 2013 04:57
-
-
Save lu911/6145240 to your computer and use it in GitHub Desktop.
companion object
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
object Main { | |
def main(args: Array[String]): Unit = { | |
val p1 = Person.apply("Loup") | |
val p2 = Person("Loup") | |
} | |
class Person(val id: Int, val name: String) | |
{ | |
println("Hello " + name) | |
} | |
object Person | |
{ | |
def apply(name : String) | |
{ | |
new Person(0, name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment