how to write a function in kotlin
snippet in kotlin

how to write a function in kotlin

user8732

// 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
}