diff options
| author | anand <anand.panchdhari@gmail.com> | 2025-11-18 22:40:54 +0530 |
|---|---|---|
| committer | anand <anand.panchdhari@gmail.com> | 2025-11-18 22:40:54 +0530 |
| commit | 8597b29e143cdeae50eafae06e0d8ed900b25295 (patch) | |
| tree | 065a09c30fa7087937d94f3207254dfe042de90a /exercises/03_if | |
| parent | f80fbca12e47014a314e5e931678529c28cd9fd8 (diff) | |
Completed till exercise 4
Diffstat (limited to 'exercises/03_if')
| -rw-r--r-- | exercises/03_if/if1.rs | 1 | ||||
| -rw-r--r-- | exercises/03_if/if2.rs | 4 | ||||
| -rw-r--r-- | exercises/03_if/if3.rs | 4 |
3 files changed, 6 insertions, 3 deletions
diff --git a/exercises/03_if/if1.rs b/exercises/03_if/if1.rs index e5a3c5a..8036c89 100644 --- a/exercises/03_if/if1.rs +++ b/exercises/03_if/if1.rs @@ -4,6 +4,7 @@ fn bigger(a: i32, b: i32) -> i32 { // Do not use: // - another function call // - additional variables + if a > b { a } else { b } } fn main() { diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs index ca8493c..8104487 100644 --- a/exercises/03_if/if2.rs +++ b/exercises/03_if/if2.rs @@ -2,8 +2,10 @@ fn picky_eater(food: &str) -> &str { if food == "strawberry" { "Yummy!" + } else if food == "potato" { + "I guess I can eat that." } else { - 1 + "No thanks!" } } diff --git a/exercises/03_if/if3.rs b/exercises/03_if/if3.rs index 89164eb..96f81f9 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -3,11 +3,11 @@ fn animal_habitat(animal: &str) -> &str { let identifier = if animal == "crab" { 1 } else if animal == "gopher" { - 2.0 + 2 } else if animal == "snake" { 3 } else { - "Unknown" + 0 }; // Don't change the expression below! |
