Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3880

Optional Assignment Operator

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • syntax
    • None

    Description

      I find myself writing a lot of code in the following form:

      if(data.field) obj.field = data.field
      // Or
      obj.field = data.field?: obj.field

      It would be nice to have a groovy operator to handle this for me.

      obj.field ?= data.field

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              blacktiger Michael Martz
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: