0

why using lambdas? for replacing single line functions with single line of code?

21st Oct 2016, 7:30 AM
Kiran K L
Kiran K L - avatar
4 Réponses
+ 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).
31st Oct 2016, 5:25 PM
Wombato Wom
Wombato Wom - avatar
0
cannot edit my post *don't like or use
31st Oct 2016, 5:28 PM
Wombato Wom
Wombato Wom - avatar
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
17th Nov 2016, 6:06 AM
Tamer Borg
Tamer Borg - avatar
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.
9th Dec 2016, 9:11 PM
Andrés Fernando Foronda Espinal
Andrés Fernando Foronda Espinal - avatar