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

Ranges removing the dot from strings when used on variables

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Won't Fix
    • 1.1-rc-3
    • 1.5
    • None
    • None

    Description

      This code:

      
      class Foo {
          static testStatic(version) {
              staticTrimTag(version)
          }
          private static staticTrimTag(pluginVersion) {
              def i = pluginVersion.indexOf('-')
              if(i>-1)
                  pluginVersion = pluginVersion[0,i-1]
              pluginVersion
          }
      
          
      }
      
      version = "1.0-SNAPSHOT"
      pluginVersion = version
      i = version.indexOf('-')
      
      println "1.0-SNAPSHOT"[0..i-1]
      println Foo.testStatic("1.0-SNAPSHOT")
      

      Prints

      1.0
      10
      

      Why?

      Attachments

        Activity

          People

            ait Alex Tkachman
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: