Community
Participate
Working Groups
Semantics should be the same as in Java. A final fields may be written ones in a constructor or it has to have an initializer. See also bug 343103
Immutable fields are ubiquitous in the functional, composition-oriented programming style which Xtend itself encourages. (For some arguments, see http://javarizon.wordpress.com/2010/06/26/why-every-java-field-should-have-been-final-by-default among many others.) I know Xtend's design principle is to stay as close to Java as possible, but I'd propose, if it's already unfortunately not part of the language by design, to make it as easy to declare as possible (e.g. use another keyword like 'const' which is shorter and doesn't overload the other meanings of the final keyword).
Proposed syntax: class Person { val myNumber = 42 // final var foo = "default" // non-final String anotherFoo = "default" // non-final static val MY_CONSTANT = "foo bar baz" var String name }
*** Bug 371958 has been marked as a duplicate of this bug. ***
pushed to master
Requested via bug 522520. -M.