|
|
@ -128,23 +128,23 @@ name = "if1"
|
|
|
|
path = "exercises/if/if1.rs"
|
|
|
|
path = "exercises/if/if1.rs"
|
|
|
|
mode = "test"
|
|
|
|
mode = "test"
|
|
|
|
hint = """
|
|
|
|
hint = """
|
|
|
|
It's possible to do this in one line if you would like!
|
|
|
|
如果你愿意的话,也可以用一行来做这件事!
|
|
|
|
Some similar examples from other languages:
|
|
|
|
其他语言中的一些类似例子:
|
|
|
|
- In C(++) this would be: `a > b ? a : b`
|
|
|
|
- 在 C(++) 中会是: `a > b ? a : b`
|
|
|
|
- In Python this would be: `a if a > b else b`
|
|
|
|
- 在 Python 中会是: `a if a > b else b`
|
|
|
|
Remember in Rust that:
|
|
|
|
请记住在 Rust 中:
|
|
|
|
- the `if` condition does not need to be surrounded by parentheses
|
|
|
|
- `if` 的条件不需要用圆括号括起来
|
|
|
|
- `if`/`else` conditionals are expressions
|
|
|
|
- `if`/`else` 的条件是表达式
|
|
|
|
- Each condition is followed by a `{}` block."""
|
|
|
|
- 每个条件后面都有一个 `{}` 块。"""
|
|
|
|
|
|
|
|
|
|
|
|
[[exercises]]
|
|
|
|
[[exercises]]
|
|
|
|
name = "if2"
|
|
|
|
name = "if2"
|
|
|
|
path = "exercises/if/if2.rs"
|
|
|
|
path = "exercises/if/if2.rs"
|
|
|
|
mode = "test"
|
|
|
|
mode = "test"
|
|
|
|
hint = """
|
|
|
|
hint = """
|
|
|
|
For that first compiler error, it's important in Rust that each conditional
|
|
|
|
对于第一个编译错误,在于 Rust 中的重要一点:
|
|
|
|
block return the same type! To get the tests passing, you will need a couple
|
|
|
|
每个条件块(conditional block)都必须返回相同的类型。
|
|
|
|
conditions checking different input values."""
|
|
|
|
为了通过测试,你需要几个条件用来判断不同的输入"""
|
|
|
|
|
|
|
|
|
|
|
|
# TEST 1
|
|
|
|
# TEST 1
|
|
|
|
|
|
|
|
|
|
|
|