Sectie 3. Hoofdstuk 4
single
Challenge: Apply Safe Execution Patterns
Veeg om het menu te tonen
Taak
Swipe to start coding
Refactor the divideNumbers function to use safe execution patterns for division in PHP.
- Validate that both
numeratoranddenominatorare numbers. - If either argument is not a number, throw an
InvalidArgumentException. - If
denominatoris zero, throw aDivisionByZeroError. - If validation passes, return the result of dividing
numeratorbydenominator.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 4
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.