Function Literals

fun main() {
  //Anonymous Function:
  var getProduct = fun(num1: Int, num2: Int): Int {
return num1 *num2
  }
  println(getProduct(8, 3))
  //Prints: 24
//Lambda Expression
  var getDifference = { num1: Int, num2: Int -> num1 -num2 }
  println(getDifference(10, 3))
  //Prints: 7
}
Comments