Improving the signIn() function using Lambda functions

Lambda functions are nothing but functions without a name. We used to call them anonymous functions. A function is basically passed into a parameter of a function call as an expression. They are very useful. They save us a lot of time by not writing specific functions in an abstract class or interface.

Lambda usage can be as simple as the following code snippet, where it seems like we are simply binding a block to some property. But that property can be invoked as a function. "hello is actually a Lambda function.":

fun main(args: Array<String>) {    val hello = { println("Hello from ServerlessWithKotlin team!") }    hello()}

At the same time, the Lambda can be a bit complex, just like the following ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.