String or Int

Report a typo

Write an implementation of a function named isNumber that determines if String can be converted to Int . If it can, then return its Int value, otherwise return the same String. Note that the return type of this function is Any, as it can return either an Int or a String.

Tip: You can use String function .toIntOrNull()

Sample Input 1:

1

Sample Output 1:

1
Write a program in Kotlin
fun isNumber(input: String) : Any // write this function
___

Create a free account to access the full topic