Should I use Lambdas or Functions?
# general-advice
y
Should I use Lambdas or Functions?
as of now i see that Lambdas are better , they are more flexible because they are assigned to a variable which you can control and you don't need to write the word
return
to return something, the only draw back is named arguments, which you cant do when calling a lambda but is there any thing that happens differently internally such as performance?
f
I'm pretty sure, that on the JVM, lambda's will be (anonymous) functions internally. So I don't think there's much performance difference between the two. (Haven't tested performance difference, this is an assumption) I would say, use whatever makes your code most readable.
👍 1
c
Do you have a specific situation in which you're curious which to use? In general, both have their strengths and weaknesses
y
no not really just in general, can you elaborate more on the strengths and weaknesses?
c
Honestly there are so many different possible situations that I don't know where to start with. Are you interested with call-site? Declaration-site? Are you a library author? Are you using local functions? How much do you care about performance? etc