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

Println behavior for collections, strings and gstrings [minor breaking change]

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.6-rc-2
    • None
    • None

    Description

      The println behavior for strings in collections is confusing. There should be no exclamation mark in line 8 of the following script. It is particularly confusing, as the behavior is different for strings and gstrings.

      import org.codehaus.groovy.runtime.InvokerHelper
      
      def g = 'g'
      def string = 'groovy'
      def gString = "${g}roovy"
      println string // groovy
      println gString // groovy
      println([string]) // ["groovy"]  !!!!! This should be [groovy]
      println([string].toString()) // [groovy]
      System.out.println([string]) // [groovy]
      println([gString]) // [groovy]
      
      // The culprit
      assert '"groovy"' == InvokerHelper.format(string, true)
      

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              hans_d Hans Dockter
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: