commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (JEXL-182) null coalesce operator
Date Thu, 03 Dec 2015 06:42:11 GMT

     [ https://issues.apache.org/jira/browse/JEXL-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Biestro resolved JEXL-182.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 3.0

The 'elvis' (?:) operator is implemented in 3.0.
{code}x ? x : y{code} can be written as {code}x ?: y{code}

> null coalesce operator
> ----------------------
>
>                 Key: JEXL-182
>                 URL: https://issues.apache.org/jira/browse/JEXL-182
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 2.1.1
>         Environment: all
>            Reporter: Terefang Verigorn
>            Assignee: Henri Biestro
>            Priority: Trivial
>              Labels: features
>             Fix For: 3.0
>
>
> common code often has constructs along the lines of:
> String r = ((v != null) ? v : "default");
> wouldnt this be better handled by a simple operator ?
> groovy has "?:" (http://www.groovy-lang.org/operators.html#_elvis_operator)
> like:
> def r = (v ?: 'default');
> and php 7 now has '??' (http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op)
> like:
> $r = ($v ?? 'default');



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message