Why the ? readline() to be able to convert it?

Why do I have to enter a ? or a!! before the .toInt() expression? What is the rationale behind it? excuse if I ask questions maybe stupid but I can not use one thing without knowing its operation or the motivation of certain choices

The .toInt extension function is defined for a receiver of type String.
readLine() returns a String?

2 Likes

Oh, thanks i’m soo stupid :sweat_smile:

1 Like

I see i can use the !! why this and what change from ?

1 Like

I’m not entirely sure what’s that you’re asking, however,

This is the documentation for ?.:
https://kotlinlang.org/docs/reference/null-safety.html#safe-calls
And this is the documentation for !!:
https://kotlinlang.org/docs/reference/null-safety.html#the--operator

2 Likes

Thanks, I’m sorry for bad English I’m Italian and I’m trying to don’t use any translator. Thanks a lot for help me to Understand this fantastic language

2 Likes