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

"as" does not convert strings to integer types

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6, 1.6-beta-1
    • Fix Version/s: 1.5.7, 1.6-beta-2
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      The following does not work in Groovy, but it should:

      def n = "2345"
      assert (n as Integer) == 2345
      

      The above code currently throws a ClassCastException.

        Attachments

        1. AsTest.groovy
          1 kB
          Peter Ledbrook
        2. GROOVY-2928.patch
          0.9 kB
          Peter Ledbrook

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              pledbrook Peter Ledbrook
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: