guard checks a condition and exits the function if it fails:
guard
fn process(name: str?) -> str { guard name != nil else { return "Name required" } let present_name = name ?? "" return "Hello, {present_name}!" }
Goal: Implement validate_age that returns "Adult" or "Minor" using guard.
validate_age
Run the code to see the output
9 results