kotlin return string in function code example
Example 1: kotlin variable in string
//Kotlin variable in string
//variables go in a ${} in a string, example
println("Happy ${age}th birdthday, ${name}!"
Example 2: return type in kotlin function
//Function having two Int parameters with Int return type
fun sum(a: Int, b: Int): Int {
return a + b
}
Example 3: how to write a function in kotlin
// Use 'fun' keyword to declare function
// 'num' is the parameter and is of type Int
// The ':Int' indicates the return type
fun square(num: Int):Int {
return num * num
}