Kotlin - Functions
OOP, it additionally needs an arrival type and an alternative contention posting
We are characterizing a capacity known as MyFunction and from the essential element we are calling this trademark and passing a couple argument.
a snicker primary(args: Array<String>) println(MyFunction("Welookups.Com")) a snicker MyFunction(x: String): String var c:String = "Hi!! Welcome To - " return (c+x)output Hi!! Welcome To - Welookups.Com
The trademark must be announced as pursues −
Lambda is an over the top stage work that altogether decreases the standard code even as confirming a trademark and characterizing the equal.
In Kotlin, you may proclaim your lambda and pass that lambda to a function.
fun main(args: Array<String>) val mylambda :(String)- >Unit = s:String->print(s) val v:String = "Welookups.Com" mylambda(v)
Now, we can skip a lambda to any other characteristic to get our output which makes the calling feature an inline function.
fun foremost(args: ArrayHeyyy!!!Welookups.Com
) val mylambda:(String)->Unit = s:String->print(s) val v:String = "Welookups.Com" myFun(v,mylambda) //passing lambda as a parameter of another function amusing myFun(a :String, movement: (String)->Unit) //passing lambda print("Ohhh!!!") movement(a)// call to lambda feature