We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b6e2e6f commit d0cb6a5Copy full SHA for d0cb6a5
_zh-cn/tour/basics.md
@@ -167,12 +167,17 @@ println("Hello, " + name + "!")
167
还有一些其他的区别,但是现在你可以认为方法就是类似于函数的东西。
168
169
方法也可以有多行的表达式。
170
+
171
+{% scalafiddle %}
172
```tut
173
def getSquareString(input: Double): String = {
174
val square = input * input
175
square.toString
176
}
177
+println(getSquareString(2.5)) // 6.25
178
```
179
+{% endscalafiddle %}
180
181
方法体的最后一个表达式就是方法的返回值。(Scala中也有一个`return`关键字,但是很少使用)
182
183
## 类
0 commit comments