Created
February 13, 2015 14:11
-
-
Save shigemk2/3619567dcd2f1b99c50c to your computer and use it in GitHub Desktop.
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
class Person(var firstName: String, var lastName: String) { | |
println("the constructor begins") | |
// some class fields | |
private val HOME = System.getProperty("user.home") | |
var age = 0 | |
// some methods | |
override def toString = s"$firstName $lastName is $age years old" | |
def printHome { println(s"HOME = $HOME") } | |
def printFullName { println(this) } // uses toString | |
printHome | |
printFullName | |
println("still in the constructor") | |
} | |
val p = new Person("Adam", "Meyer") | |
println(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment