Skip to content

cotrFuncLambda

Creates a lambda (anonymous) function

Aliases:

  • cotrFuncLambda
  • cotrFuncAnon
  • cotrLambda
  • cotrFuncArrow
  • anonFunc
  • anonymous
  • functionLiteral
  • lambda
  • arrowFunc
  • closure

cpp

auto myLambda = [](parameters) -> returnType {
// Your code here
};
// Or without assigning to a variable:
[](parameters) -> returnType {
// Your code here
}

csharp

(parameters) => expression

haskell

\parameters -> expression
-- Usage example
let myFunc = \parameters -> expression
in myFunc arguments

java

(parameters) -> expression

kotlin

val myLambda: (ParameterType) -> ReturnType = { parameters ->
expression
}

php

function (parameters) => expression

powershell

Terminal window
# PowerShell does not have a 'lambda' keyword.
# Instead, script blocks are used as anonymous functions.
lambda = {
param(parameters)
# Your code here
}
# Usage
result =lambda.Invoke(arguments)
Write-Host "Result:result"

ruby

my_function = ->(parameters) {
# Your code here
}

scala

(parameters) => expression

shellscript

Terminal window
# Bash doesn't have lambda functions.

typescript

const myLambda = (parameters) => expression;

typescriptreact

const myLambda = (parameters) => expression;