commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JEXL-276) Introduce short-handed ternary operation x ? y
Date Mon, 17 Sep 2018 15:46:00 GMT
Dmitri Blinov created JEXL-276:
----------------------------------

             Summary: Introduce short-handed ternary operation x ? y
                 Key: JEXL-276
                 URL: https://issues.apache.org/jira/browse/JEXL-276
             Project: Commons JEXL
          Issue Type: Improvement
    Affects Versions: 3.1
            Reporter: Dmitri Blinov


A short-handed ternary operation {{x ? y}} is an equivalent of the {{x ? y : null}}. The {{x
: y}} operator is analogous to {{if (x) y}} statement with {{else}} part omitted. With new
syntax we will have ternary operator and {{if}} statement to have full symmetry of forms,
e.g.
{{x ? y : x}} is {{if (x) y else z}}, {{x ? y}} is {{if (x) y}}

Just to note, the proposed short-handed differs from Elvis operator {{x ?: y}} which is effectively
{{x ? x : y}}. In other words, elvis operator allows for the middle part of the ternary operator
to be omitted, whereas the proposed form allows for the imission of the last part. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message