elvis pattern refinement (was Syntax patterns)

Stephen Colebourne scolebourne at joda.org
Fri Apr 24 09:45:21 PDT 2009

2009/4/24 Ruslan Shevchenko <rssh at gradsoft.com.ua>:
> But I mean this is incorrect, becouse it does not cover case of
> 'null-safe method call' (which is often used for describing elvis).

Officially, 'Elvis' just refers to the 'default if null' pattern. The
other operators are the 'null-safe' operators.

> So, for example, in jetty we see only one matching for four patterns.
> More - rereading  proposal, I see that I implement check for 'safe method
> call' but in proposal we have 'safe index; safe field access, .. etc)
> So, let's explicit define all aviable patterns.
> First question: is 'safe-method call': i. e.
> (a==null ? b : a.method(...)) pattern is correct ?
> // Which can be rewritten as    a?.method() ?: b

If I were writing Java today without the null-safe operators, then I
would typically use an if-statement:

if (foo != null) {

Bar bar = null;
if (foo != null) {
  bar = foo.process();


More information about the coin-dev mailing list