if (obj is String && obj.length > 0) {
return obj.length
}
return null
}
Why is it Int here?
s
shady-dom
04/30/2018, 2:28 AM
Int being the return type, the
?
basically says “forget the type, I can be null too”
shady-dom
04/30/2018, 2:29 AM
So,
fun getStringLength(obj: Any): <Int or null> {
c
crazdrms
04/30/2018, 2:33 AM
got it , it just made sense, I was reading it as returning String or null. Got my self confused. I just saw it was returning length of String which is Int 🤦♂️ . Thanks.
s
shady-dom
04/30/2018, 2:33 AM
You’re welcome!
a
Andreas Sinz
04/30/2018, 12:01 PM
@crazdrms for future occasions, please surround multi-line code with 3 backticks