Difference between expression lambda and statement lambda

后端 未结 4 1359
长情又很酷
长情又很酷 2021-02-01 03:38

Is there a difference between expression lambda and statement lambda?

If so, what is the difference?

Found this question in the below link but could not understa

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 04:31

    A lambda expression is a syntax that allows you to create a function without name directly inside your code, as an expression.

    There are two kinds of lambda expressions, depending on their body:

    • expression lambdas, whose body is just an expression, e.g. (i, j) => i + j
    • statement lambdas, whose body is a full statement, e.g.. (i, j) => { return i + j; }

提交回复
热议问题