Normal vs Lambda expression or Highorder function

Lambda definition:

Kotlin has concise (short) syntax for defining lambda functions, which makes it easier to work with functional programming constructs.


Lambda Expression syntax in Kotlin:

{ argument -> businessloginwith_return }

{ a, b -> a+b }

Lambda 


fun main(args: Array<String>) {
/* Normal function
vs
lambda expression
syntax: { a, b -> a+b }
*/
/** Normal function **/
println(add(4,5))
/** Lambda function **/
val ldadd = { a:Int, b:Int ->
a+b
}
println(ldadd(3,4))
}
//Normal function
fun add(a:Int, b: Int): Int
{
return a+b
}
view raw gistfile1.txt hosted with ❤ by GitHub


Comments

Popular posts from this blog

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2.1. Cannot sync the project.

Google Assistant Implementation in Android application with app actions