Kotlin: why would you want to convert Int.toString?
21:45 10 Jan 2021

i'm still new to kotlin so take my question with a grain of salt

so i've been learning about kotlin and in one of the articles i was reading about had this code as an example of how to use .toString

val sum1 = { a: Int, b: Int -> 
    val num = a + b 
    num.toString()   //convert Integer to String 
} 
fun main(args: Array) { 
    val result1 = sum1(2,3) 
    println("The sum of two numbers is: $result1") 
} 

Output:

The sum of two numbers is: 5

as i understand it, it's a "5" but of type string.. but why??

we can just simplify the code and get the same outcome:

    val sum1 = { a: Int, b: Int -> a + b }

    val result1 = sum1(2,3)
    println("The sum of two numbers is: $result1")

output:

The sum of two numbers is: 5

so.. i've seen examples of how to use it, but i still didn't find anything to explain why you'd want to use it

android kotlin