Seção 3. Capítulo 4
single
Challenge: Apply Safe Execution Patterns
Deslize para mostrar o menu
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo