mvel , or MVFLEX expression language has rich syntax , many of which allow you to use more concise and expressive code (and less imperative) than java , for example
- Abbreviation for
get() ters / set() ters (for example, encapsulating private fields), access to which is possible in the alternative property style syntax (similar to VB or C # properties in .Net )
t. instead
myObject.setSomeField("SomeValue"); int x = myObject.getSomeIntField();
You can use the syntax (note the thin key of capitalization):
myObject.someField = "SomeValue" x = myObject.someIntField // Type inferrence
- The
return is optional (the convention is found in many functional languages ββsuch as Scala), as well as the colon, if you do not have multiple statements in the line:
x // ie return x;
- Creating and indexing a string array by sequence numbers
foos = {2, 4, 6, 8, 10} foos[3] // foos.get(3)
- Similarly for cards (dictionaries)
bars = ["a" : "Apple", "b" : "Basket"] // Hashmap, with put bars["a"] bars.a // Similar to dynamically typed object eg in javascript, if key is a string.
- Null Safe navigation operator (for example, a null condition operator in Rosyln)
foo.?bar.baz // if (foo.bar != null) { return foo.bar.baz; } else { return null; }
source share