Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-182

null coalesce operator

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 3.0
    • Labels:
    • Environment:

      all

      Description

      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');

        Attachments

          Activity

            People

            • Assignee:
              henrib Henri Biestro
              Reporter:
              terefang Terefang Verigorn
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: