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

Groovy fails to set field without qualifying with "this"

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 1.0-JSR-1
    • 1.0-JSR-5
    • None
    • None

    Description

      Consider the following code:

      def x = 5

      def test() {
      x = 6
      }

      test()
      println x

      The expected result is 6.
      The actual result is 5.
      Workaround: use the "this" keyword i.e. this.x = 6

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            jaquino Jonathan Aquino
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment