orElse supplies a fallback action when a computation fails, letting the chain recover instead of stopping at the first error. In this treatment, it appears as the branch that logs a missing student after a lookup fails, complementing default-value handling with getOrElse. section 5.3
It fits the Either pattern, where successful values stay on the right and failures carry error information on the left. The fallback can be another function, so the failure path remains explicit and reusable.
Used here to handle failure cases by handoff, not by throwing away the error:
- returns a default value with getOrElse when only a substitute result is needed section 5.3
Logging a failed student lookup
findStudent('444-44-4444').orElse(errorLogger) sends the failure branch to a logger instead of trying to extract a value immediately.
