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

Differences between StringBuffer.append und String +

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      The Script

      class Test {
      public String toString()

      { super.toString() + properties }

      }
      println new Test()

      produces:
      Test@2a5330["metaClass":groovy.lang.MetaClassImpl@1b383e9[class Test], "class":class Test]

      but the Script

      class Test {
      public String toString()

      { new StringBuffer(super.toString()).append(properties) }

      }
      println new Test()

      produces:
      Test@13c1b02

      {metaClass=groovy.lang.MetaClassImpl@91cee[class Test], class=class Test}

      Is that a bug? I would think this should produce the same result. If the first class would be compile it should generate something like the second class. So this could also be a difference between scripts and compiled code? (I will try this if I got the time.)

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              jogi Jörg Gottschling
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: