Suggested approach: The nil coalescing operator (
??) lets you provide a default value to use if an optional value is empty. I would probably add that optionals are a really useful language feature in Swift, but if I can ditch them – if I can get a
String rather than a
String? – then I do, and that's where nil coalescing is really useful.
Estimated difficulty: Easy
CaseIterable protocol do?
guard keyword in Swift?
Link copied to your pasteboard.