Skip to content

Commit 0afef9f

Browse files
authored
Merge pull request #2349 from TSLsun/fix_code_example_in_tour_classes
Fix compiling warnings in a code example of tour/classes
2 parents b292ee9 + f874fe3 commit 0afef9f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_tour/classes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ class Point {
7676
private var _y = 0
7777
private val bound = 100
7878

79-
def x = _x
79+
def x: Int = _x
8080
def x_= (newValue: Int): Unit = {
81-
if (newValue < bound) _x = newValue else printWarning
81+
if (newValue < bound) _x = newValue else printWarning()
8282
}
8383

84-
def y = _y
84+
def y: Int = _y
8585
def y_= (newValue: Int): Unit = {
86-
if (newValue < bound) _y = newValue else printWarning
86+
if (newValue < bound) _y = newValue else printWarning()
8787
}
8888

89-
private def printWarning = println("WARNING: Out of bounds")
89+
private def printWarning() = println("WARNING: Out of bounds")
9090
}
9191

9292
val point1 = new Point

0 commit comments

Comments
 (0)