0
why using lambdas? for replacing single line functions with single line of code?
4 Respostas
+ 1
use lambdas when you need a quick inline function.
they are often used with methods that require functions as arguments, like map or filter. so if you want all your lists elements multiplicated by some value you can use map with a lambda for example.
they are used for really simple tasks.
i personally don't very much anonymous functions because without a name they are difficult to track and can lead to various issues (only my personal opinion).
0
cannot edit my post
*don't like or use
0
lambda
An anonymous inline function consisting of a single expression which is evaluated when the function is called. The syntax to create a lambda function is
lambda [arguments]: expression
0
Look, You need 2 or more lines for a named function, what if do you need just use a function one time?, whit Lambda you can put one code line and make the same thing, so, you need less memory for this operation.