-1 I agree with Anne and the others; I see no compelling use case for this. If making variable definitions line up is the goal then make your variable definitions line up... that is what whitespace was invented for. And I can't think of a single keyword (other than "final" or "const") that would make me think, "Hey, that variable can't be changed".
- Keith > On Apr 28, 2020, at 8:09 AM, mojo2012 <meister.fu...@gmail.com> wrote: > > Dear development community, > > I'm a long time java developer and I'm used to add "final" to my variable > definition: final var name = "a" > > I think the *"var"* keyword (and the old "*def*" keyword) itself helps a > lot, but seeing "*var*" and "*final var*" not being aligned properly in code > makes me crazy. > > As we have def and var in groovy, wouldn't it be nice to have a val or let > in groovy too, that is just a short form of "final var"? > > Although personally I would prefer "*val*" I do understand that some people > might have problems differentiating "*var*" and "*val*", hence the "*let*". > Both *Kotlin* and *Scala* went for the "val" keyword as well - so it might > not bee too bad. > > Anyway I created a JIRA ticket for this: > https://issues.apache.org/jira/browse/GROOVY-9308 > And I created a *patch PR*: https://github.com/apache/groovy/pull/1236 > > The patch as of now contains both the "let" and "val" syntax. I added tests > to check if the actual variable is final. Those tests all seem find. But I > wasn't able to see "final val" as syntax error (so the test currently > fails). > > I'm looking forward to get some feedback from you (hopefully positive :-)) > > [ ] +1 Add either val or let as new shortcut for "final def"/"final var" > [ ] 0 I don't have a strong opinion about this, but I assume it's ok > [ ] -1 I don't like this feature because ... > > > > > > -- > Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html