Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: scrollbar

...

The "." is called the "dereference operator". In addition, there is a a "safe dereference operator", "?.", which  works the same as "." except that it allows any of the properties to be null. When reading, a null short-circuits the expression (which returns null). When writing to a property, an intermediate null value will cause the value to be discarded without error.

...

 

Example

Notes

Keyword

this

 

Keyword

null

 

Property Name

userName

Calls getUserName() or setUserName, depending on context

Property Chain

user.address.city

Calls getUser().getAddress().getCity() or getUser().getAddress().setCity(), depending on context

Property Chain

user?.name

Calls getUser() and, if the result is not null, calls getName() on the result

Method Invocation

groupList.size()

calls getGroupList().size()

Method Invocation

members.findById(user.id)?.name

Calls getMembers().findById(getUser().getId()).getName() (unless findById returns null)

Range

1..10

Iterates between integers 1 and 10

Range

1..myList.size()

Iterates between 1 and the result of getMyList().size()

Literal String

'Beer is proof that God loves us and wants us to be happy.'

Use single quotes

List

[user.name, user.email, user.phone]

 

Not Operator

! user.deleted

the boolean negation of getUser().getDeleted()

Not, Coerced

! user.middleName

true only if getUser.getMiddleName() returns null or an empty string

Map

{ 'framework' : 'Tapestry', 'version' : version }

Keys are string literals (in single quotes), but could be properties as well

Scrollbar