pull/120/head
unknown 3 years ago
parent 718c89ea91
commit 1ae471dcf5

@ -1,7 +1,7 @@
# If
`if`, the most basic type of control flow, is what you'll learn here.
你将在这学习最基本的控制流control flow——`if`
## Further information
## 更多信息
- [Control Flow - if expressions](https://doc.rust-lang.org/book/ch03-05-control-flow.html#if-expressions)

@ -3,14 +3,14 @@
// I AM NOT DONE
pub fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - another function call
// - additional variables
// Execute `rustlings hint if1` for hints
// 完成这个返回更大数字的函数!
// 但不允许以下方式:
// - 调用其它函数
// - 额外变量
// 执行 `rustex hint if1` 获取提示
}
// Don't mind this for now :)
// 暂时不要在意它 :)
#[cfg(test)]
mod tests {
use super::*;

@ -1,8 +1,8 @@
// if2.rs
// Step 1: Make me compile!
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute the command `rustlings hint if2` if you want a hint :)
// 第一步:让我能够编译!
// 第二步bar_for_fuzz 和 default_to_baz 可以通过测试!
// 执行 `rustex hint if2` 获取提示 :)
// I AM NOT DONE
@ -14,7 +14,7 @@ pub fn fizz_if_foo(fizzish: &str) -> &str {
}
}
// No test changes needed!
// 测试不需要更改。
#[cfg(test)]
mod tests {
use super::*;

@ -128,23 +128,23 @@ name = "if1"
path = "exercises/if/if1.rs"
mode = "test"
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`
- In Python this would be: `a if a > b else b`
Remember in Rust that:
- the `if` condition does not need to be surrounded by parentheses
- `if`/`else` conditionals are expressions
- Each condition is followed by a `{}` block."""
!
:
- C(++) : `a > b ? a : b`
- Python : `a if a > b else b`
Rust
- `if`
- `if`/`else`
- `{}` """
[[exercises]]
name = "if2"
path = "exercises/if/if2.rs"
mode = "test"
hint = """
For that first compiler error, it's important in Rust that each conditional
block return the same type! To get the tests passing, you will need a couple
conditions checking different input values."""
Rust
conditional block
"""
# TEST 1

Loading…
Cancel
Save