getOrElse returns the wrapped value when it exists, and a default value when it does not. It is used with Maybe-style values to avoid scattered null checks and to supply a safe fallback at the end of a chain. section 5.3
A common pattern is to map through several fields and finish with getOrElse. That keeps the missing-value handling in one place instead of branching at every step. section 5.3
Fallback after a lookup chain
A student lookup can be mapped to firstname for display, then finished with getOrElse('Enter first name'). A country lookup can map school, address, and country before returning 'Country does not exist!'.
Typical uses shown here include:
- displaying a form field value or a placeholder when no data is available. section 5.3
