Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if exercises completed #3

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions exercises/03_if/if1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
//
// 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 {
// Complete this function to return the bigger number!
// Do not use:
// - another function call
// - additional variables
if (a<b){
b
} else {
a
}
}

// Don't mind this for now :)
Expand Down
7 changes: 4 additions & 3 deletions exercises/03_if/if2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
//
// 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 {
if fizzish == "fizz" {
"foo"
} else {
1
} else if fizzish == "fuzz"{
"bar"
} else{
"baz"
}
}

Expand Down
5 changes: 2 additions & 3 deletions exercises/03_if/if3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
//
// 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 {
let identifier = if animal == "crab" {
1
} else if animal == "gopher" {
2.0
2
} else if animal == "snake" {
3
} else {
"Unknown"
4
};

// DO NOT CHANGE THIS STATEMENT BELOW
Expand Down