Difference between expression lambda and statement lambda

后端 未结 4 1357
长情又很酷
长情又很酷 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条回答
  •  一生所求
    2021-02-01 04:33

    Yes there is - or I should probably say that one defines the other.

    A lambda expression allows you to assign simple anonymous functions.

    An expression lambda is a type of lambda that has an expression to the right of the lambda operator.

    The other type of lambda expression is a statement lambda because it contains a statement block {...} to the right side of the expression.

    • Expression lambda takes the form: number => (number % 2 == 0)
    • Statement lambda takes the form: number => { return number > 5 }

提交回复
热议问题