Seção 2. Capítulo 4
single
Challenge: Add Exception Throwing to a Function
Deslize para mostrar o menu
Tarefa
Swipe to start coding
Update the calculateDivision function to throw exceptions for invalid data, and ensure the main program handles these exceptions using try/catch blocks.
- If either
$numeratoror$denominatoris not numeric, throw anInvalidArgumentException. - If
$denominatoris zero, throw aDivisionByZeroError. - If both arguments are valid and the denominator is not zero, return the result of dividing
$numeratorby$denominator.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo