Lambadas in kotlin programming language

Lambadas are similar to arrow functions in JavaScript they are a short alternative method to declare functions in kotlin programing language, You can create a function expression as;

val double = {num: Int -> num * 2}
val cube = { num: Int -> num * num * num}
val square = {num: Int ->
    val product = num * num
    product }

The last expression in a lambada is considered as a return value;
Parameters can be omitted, for a single parameter lambada the value of the omitted parameter is in the variable 'it'

Comments

Popular posts from this blog

FlappingBird Postmortem (JS13K)

JavaScript introduction to variables

FlappingBird JS13K Games

How to target all elements of a given class name in JavaScript

Zedplug will be decommissioned on November 30th