Loading lesson…
Level 1 · Apprentice0 XP
Model every possible state and let the compiler tell you when you missed one.
Step 1 / 5
ProblemA screen has isLoading, an error string and data. They can be set in impossible combinations: loading with an error, data and an error together. Every reader has to guess which is real.
← → step
Before this: Extensions and scope functions
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Model a payment result as a sealed interface with Paid(receiptId), Declined(reason) and Pending. Write message(result) with an exhaustive when and no else. Then add Refunded and let the compiler show you what to update.