Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created February 19, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/6be9ffdc1e092a827d93 to your computer and use it in GitHub Desktop.
Save shigemk2/6be9ffdc1e092a827d93 to your computer and use it in GitHub Desktop.
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")
}
object Person {
def main(args: Array[String]) {
new Person("Alan", "Smithee")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment