|
|
|
|
|
by jimbokun
5495 days ago
|
|
"Perhaps your original point stands that in Clojure you have _better_ visual clues for picking out anonymous functions at a glance" Yes, this is what I was trying to get at. Thanks for clarifying the examples, though. So, using _ in any expression makes that expression an anonymous function? Is _ by itself the identity function? |
|
Ah, I should have said - the syntax above only works with one-liners. The following wouldn't work:
etc.Instead you would need to explicitly surround the method body with curly brackets:
And in this case, it's obvious what is happening.So it's more like providing a one line expression where a function is expected makes it an anonymous function. The use of _ is simply a shortcut when you don't need to assign parameters to a local variable. It even works with multiple parameters. I.e. compare:
To: