[Work] exercises/if

This commit is contained in:
Phan Huy Hoang 2023-01-01 00:29:02 +07:00
parent f584742608
commit e3a6bf17a2
2 changed files with 8 additions and 5 deletions

View File

@ -1,9 +1,12 @@
// if1.rs // if1.rs
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn bigger(a: i32, b: i32) -> i32 { pub fn bigger(a: i32, b: i32) -> i32 {
if a > b {
a
} else {
b
}
// Complete this function to return the bigger number! // Complete this function to return the bigger number!
// Do not use: // Do not use:
// - another function call // - another function call

View File

@ -4,13 +4,13 @@
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing! // Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn foo_if_fizz(fizzish: &str) -> &str { pub fn foo_if_fizz(fizzish: &str) -> &str {
if fizzish == "fizz" { if fizzish == "fizz" {
"foo" "foo"
} else if fizzish == "fuzz" {
"bar"
} else { } else {
1 "baz"
} }
} }