We have to specify function names while creating them. However, there is a special class of functions for which we do not need to specify function names.
Definition
A lambda is an anonymous function that returns some form of data.
Lambdas are defined using the lambda keyword. Since they return data, it is a good practice to assign them to a variable.
Syntax#
The following syntax is used for creating lambdas:
svg viewer
In the structure above, the parameters are optional.
Let’s try creating a few simple lambdas.
Below, we can find a lambda that triples the value of the parameter and returns this new value: