May I know if the type of *result* is inferred at ...
# getting-started
m
May I know if the type of result is inferred at Runtime ? If not, what is it called ? Here, Value of result is either "HelloString" or 2
Copy code
while (index < 3) {  
        index ++

        val result = cakesList?.let{ 
                 if(index == 2) {
                     "HelloString"
                 } else {
                  2   
                 }
            } 

        println("result value = $result")

        when(result) {
          is String -> println(" result variable is a String")

          is Int -> println(" result variable is Integer")
}
o
If your using IntelliJ then, Alt + Enter then show property type hints
i think it will be Any
s
it will be Any? because of the ?.
m
Ya. Thanks