Library code

Report a typo

You have a function from the library (already in the task scope). You can't open its source code, but you know that the prototype looks like this:

def parseSpecialNumber(s: String): Int

This function can throw errors. Fix the code so that the tryPrintSpecialNumber catches all errors and prints their message. If successful, the function should just print the number that is returned.

Sample Input 1:

42^

Sample Output 1:

Unexpected char: ^
Write a program in Scala 3
def tryPrintSpecialNumber(s: String): Unit =
println(parseSpecialNumber(s))
___

Create a free account to access the full topic