4 ms·
What's wrong with using a nested named functions instead? You may already be aware, but not everyone is: they capture variables from outer scopes in exactly th
by quietbritishjim 6y ago
What's wrong with using a nested named functions instead?
You may already be aware, but not everyone is: they capture variables from outer scopes in exactly the same way that lambdas do.
- heavyset_go 6y agoIt's just more pleasant to be able to write anonymous functions and to be able to extend them past a single line. If I had to name all of my anonymous functions that I write in other languages, I'd find another way to accomplish what I was trying to do with them.
- netheril96 6y agoIt's wrong because naming is hard. When writing inline, it is possible that not having a name does not impact readability. When defining the function out of line, naming it casually may confuse readers.
- bhargav 6y agoWhen we use lambdas, don't we usual end up assigning them to variables? In those cases, your point about naming will still hold!
- silveraxe93 6y agoLambdas are assigned to function arguments/parameters. Pretty sure assigning a lambda to a variable is an anti-pattern.