Skip to content

Commit ecd4cca

Browse files
author
Alexander Rogalskiy
committed
Updates on files
1 parent a838bfb commit ecd4cca

File tree

1 file changed

+23
-0
lines changed
  • patterns/src/main/kotlin/io/nullables/api/playground/patterns/parent_call

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.nullables.api.playground.patterns.parent_call
2+
3+
class Greeting(val word: String)
4+
5+
open class Father {
6+
init {
7+
sayGreeting()
8+
}
9+
10+
open fun sayGreeting() = println("Luke! I'm your Father!!!")
11+
}
12+
13+
class Leia : Father() {
14+
private var greeting: Greeting? = null
15+
get() {
16+
if (field == null) {
17+
field = Greeting("I love you!")
18+
}
19+
return field
20+
}
21+
22+
override fun sayGreeting() = println(greeting!!.word)
23+
}

0 commit comments

Comments
 (0)