Java 8 lambda expression and first-class values

后端 未结 5 1522
忘了有多久
忘了有多久 2020-11-27 16:20

Are Java 8 closures really first-class values or are they only a syntactic sugar?

5条回答
  •  眼角桃花
    2020-11-27 16:34

    For me Lambdas in Java 8 is just syntax sugar because you cannot use it as First class Citizen (http://en.wikipedia.org/wiki/First-class_function) each function should be wrapped into object it imposes many limitation when comparing to language with pure first class function like SCALA. Java 8 closures can only capture immutable ("effectively final") non-local variables.

    Here is better explanation why it is syntax-sugar Java Lambdas and Closures

提交回复
热议问题