Print
MVEL 2.0 Block WITH Operator

The block with operator is a powerful construct for acting on an object instance.

Example:

The code above is functionally equivalent to:

Nesting WITH

MVEL has support for deep graph hierarchies using 'with' and inline arrays, lists and maps:

To be able to use the 'with' keyword in nested structures and in such a way that it returns a value you must encase the keyword and it's following curly braces in parenthesis, i.e. ( with(...) {...} ).

The above deep graph assignment is the equivalent of:

Inline With Operator

MVEL 2.0 introduces a new, abbreviated version of the with operator, using a dot following by an opening curly bracket, you can open up a context around that object instance. For example:

The above example demonstrates constructing an object graph with inline with notation. It is functionally equivalent to the following code:

Powered by Atlassian Confluence