Safe division

Report a typo

There is a function in the scope that divides 10 by the passed number.

def divide10(n: Int): Int = 10 / n

Complete the code of the protectedDivide function so that zero is returned in case of a division error.

Sample Input 1:

1
0

Sample Output 1:

10
0
Write a program in Scala 3
def protectedDivide(n: Int): Int =
try {
divide10(n)
} ???
___

Create a free account to access the full topic