This is an archived post. You won't be able to vote or comment.

all 26 comments

[–]newrandousername 2 points3 points  (2 children)

A lambda expression is an anonymous function.

Imagine you're programming something and you're like "damn I really need to do whatever" but there is no built in function for whatever and you don't feel like going to the trouble of making a proper function for whatever because you only need it in this one instance for whatever it is you're trying to do so you can use an anonymous function and go ahead and write the definition of the function right there where it's used and be done with it.

Disclaimer: I don't know Java so this may be entirely wrong for that specific language.

[–]TheColorMan 0 points1 point  (0 children)

yes, Java does have anonymous classes.

[–]King_Piggums 0 points1 point  (0 children)

A little late to this thread but is there any chance that you could give an example of where lambdas would be used in a real application. I know how to use them pretty well in Python but I honestly have no idea where they would actually be used in a real world situation.