Answers for "kotlin function types"

4

function kotlin

// Declare a function in Kotlin
fun happyBirthday(name: String, age: Int): String {
    return "Happy ${age}th birthday, $name!"
}
// Call function
val greeting = happyBirthday("Anne", 32)
Posted by: Guest on October-24-2020
0

kotlin function types

Function types
()->Unit - takes no arguments and returns nothing (Unit).
(Int, Int)->Int - takes two arguments of type Int
and returns Int.
(()->Unit)->Int - takes another function
and returns Int.
(Int)->()->Unit - takes argument of type Int
and returns function.
Posted by: Guest on January-15-2021

Browse Popular Code Answers by Language