Section 3. Chapitre 4
single
Challenge: Apply Safe Execution Patterns
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 4
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion