mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
Add new solution in variables ex. 4
This commit is contained in:
@ -35,6 +35,17 @@ fn main() {
|
|||||||
|
|
||||||
4.
|
4.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
define_x();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn define_x() {
|
||||||
|
let x = "hello";
|
||||||
|
println!("{}, world", x);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = define_x();
|
let x = define_x();
|
||||||
@ -141,4 +152,4 @@ fn main() {
|
|||||||
// fill the blank to make the code work
|
// fill the blank to make the code work
|
||||||
assert_eq!([x, y], [3, 2]);
|
assert_eq!([x, y], [3, 2]);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user