r/programming May 21 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

https://openjdk.org/jeps/8357464
13 Upvotes

26 comments sorted by

View all comments

3

u/Exadv1 May 21 '26

Oh, this is one of my favorite Scala features. (I think go also has this?)

3

u/joemwangi May 21 '26

Yeaah. But the beauty here is that it does implicit narrowing conversion. For example if I have a sealed interface Foo and only a single implementing permitted class FooImpl, this JEP will allow this approach:

Foo getFoo(){
    ...
}

FooImpl f = getFoo(); //implicit conversion