Merge pull request #1 from ArturZinurov/if-exercises

if complete
This commit is contained in:
Artur Zinurov 2023-12-26 20:27:33 -06:00 committed by GitHub
commit bae67e341a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\C:\\Users\\artur\\Source\\Repos\\rustlings",
"PreviewInSolutionExplorer": false
}

BIN
.vs/rustlings/v17/.suo Normal file

Binary file not shown.

View File

@ -2,13 +2,13 @@
// //
// 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! // Complete this function to return the bigger number!
// Do not use: // Do not use:
// - another function call // - another function call
// - additional variables // - additional variables
if a > b {return a} else {return b}
} }
// Don't mind this for now :) // Don't mind this for now :)

View File

@ -5,13 +5,15 @@
// //
// 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,21 +2,19 @@
// //
// 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
let habitat = if identifier == 1 { let habitat = if identifier == 1 {
"Beach" "Beach"
} else if identifier == 2 { } else if identifier == 2 {
"Burrow" "Burrow"