Skip to content

Fix Chinese Simple(zh_CN) version of issue#1339 #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _zh-cn/tour/pattern-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ x match {
case 0 => "zero"
case 1 => "one"
case 2 => "two"
case _ => "many"
case _ => "other"
}
```
上述代码中的`val x`是一个0到10之间的随机整数,将它放在`match`运算符的左侧对其进行模式匹配,`match`的右侧是包含4条`case`的表达式,其中最后一个`case _`表示匹配其余所有情况,在这里即是`x`大于2的情况
上述代码中的`val x`是一个0到10之间的随机整数,将它放在`match`运算符的左侧对其进行模式匹配,`match`的右侧是包含4条`case`的表达式,其中最后一个`case _`表示匹配其余所有情况,在这里就是其他可能的整型值

`match`表达式具有一个结果值
```tut
def matchTest(x: Int): String = x match {
case 1 => "one"
case 2 => "two"
case _ => "many"
case _ => "other"
}
matchTest(3) // many
matchTest(3) // other
matchTest(1) // one
```
这个`match`表达式是String类型的,因为所有的情况(case)均返回String,所以`matchTest`函数的返回值是String类型。
Expand Down