Here is a program that uses the check function according to this logic: if the length of the input string is greater than 5, it returns null; otherwise it returns the string. Do not change the check function: fix the output. It has to return 0 in null case.
Avoiding NPEs. Null safety
Check length
Report a typo
Sample Input 1:
dangerSample Output 1:
0Sample Input 2:
BobSample Output 2:
3Write a program in Kotlin
fun main() {
val argument = readLine()!!
println(check(argument).length)
}
// do not change function below
fun check(name: String): String? {
return if (name.length > 5) null else name
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.