Lambdas
In this lesson, we will learn about lambdas and why they are important.
We'll cover the following
There is a special class of functions for which we do not need to specify function names. These are called lambdas.
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 good practice to assign them to a variable.
Syntax #
lambda parameters: expression
In the above syntax, parameters
are optional.
Below, we can find a lambda that squares the value of the parameter and returns this new value:
Get hands-on with 1400+ tech skills courses.