docs(exercises): clarify if3 requires uniform branch types

Closes #2211

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuyangfan 2026-05-17 14:08:22 +08:00
parent db3f332507
commit 6b7f4955bb

View File

@ -1,5 +1,10 @@
fn animal_habitat(animal: &str) -> &str {
// TODO: Fix the compiler error in the statement below.
//
// Hint: every `if` / `else if` / `else` branch must produce the same type.
// A floating-point literal, a string, and integers cannot be mixed in one chain.
// For unknown animals, use another integer identifier (for example `4`) instead of
// a string, then keep the habitat checks below unchanged.
let identifier = if animal == "crab" {
1
} else if animal == "gopher" {