if statements

This commit is contained in:
Andrew Kushyk 2024-04-24 07:07:45 +00:00
parent bd1949961c
commit c45ba8f152
3 changed files with 12 additions and 11 deletions

View File

@ -2,14 +2,15 @@
// //
// 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 {
// Complete this function to return the bigger number! if a > b {
// If both numbers are equal, any of them can be returned. return a;
// Do not use: } else if a < b {
// - another function call return b;
// - additional variables }
a
} }
// Don't mind this for now :) // Don't mind this for now :)

View File

@ -5,13 +5,14 @@
// //
// 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"
} }
} }

View File

@ -2,17 +2,16 @@
// //
// Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn animal_habitat(animal: &str) -> &'static str { pub fn animal_habitat(animal: &str) -> &'static str {
let identifier = if animal == "crab" { let identifier = if animal == "crab" {
1 1
} else if animal == "gopher" { } else if animal == "gopher" {
2.0 2
} else if animal == "snake" { } else if animal == "snake" {
3 3
} else { } else {
"Unknown" 0
}; };
// DO NOT CHANGE THIS STATEMENT BELOW // DO NOT CHANGE THIS STATEMENT BELOW