summaryrefslogtreecommitdiff
path: root/scala/constructor.scala
blob: 1dd36de36100c69a4f96dd951f7af68971e226d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
class Person(firstName : String) {
    println("Outer constructor")

    def this(firstName : String, lastName : String) {
        this(firstName)
        println("Inner constructor")
    }

    def talk() = println("Hi")
}

val bob = new Person("Bob")
val bobTate = new Person("Bob", "Tate")