Skip to content

Commit 539d4aa

Browse files
authored
Docs: Improve Sample Code (#4183)
* docs: rename local variables to avoid confusion * docs: remove unnecessary keyword `val` from constructor parameter
1 parent a8a6e7e commit 539d4aa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/topics/delegation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class BaseImpl(val x: Int) : Base {
1717
class Derived(b: Base) : Base by b
1818

1919
fun main() {
20-
val b = BaseImpl(10)
21-
Derived(b).print()
20+
val base = BaseImpl(10)
21+
Derived(base).print()
2222
}
2323
```
2424
{kotlin-runnable="true"}
@@ -48,9 +48,9 @@ class Derived(b: Base) : Base by b {
4848
}
4949

5050
fun main() {
51-
val b = BaseImpl(10)
52-
Derived(b).printMessage()
53-
Derived(b).printMessageLine()
51+
val base = BaseImpl(10)
52+
Derived(base).printMessage()
53+
Derived(base).printMessageLine()
5454
}
5555
```
5656
{kotlin-runnable="true"}
@@ -64,7 +64,7 @@ interface Base {
6464
fun print()
6565
}
6666

67-
class BaseImpl(val x: Int) : Base {
67+
class BaseImpl(x: Int) : Base {
6868
override val message = "BaseImpl: x = $x"
6969
override fun print() { println(message) }
7070
}

0 commit comments

Comments
 (0)