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

Problem with vargs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-4
    • 1.0-RC-1
    • None
    • None
    • Windows 2K,
      groovy -v :
         Groovy Version: 1.0-jsr-04-SNAPSHOT JVM: 1.4.2_06-b03

    Description

      As discussed on the user-Mailinglist, there seems to be a problem with vargs.

      The following code snippets (first from me, second from Jochen Theodorou)
      present it:

      -----------------------------------------------
      Code snippet:
      def path = new File("D:/test")
      def content = Arrays.asList( path.list() )
      content.each

      { println it }

      Result:

      {"One.txt", "Three.txt", "Two.txt"}

      Expected result:
      One.txt
      Three.txt
      Two.txt

      -----------------------------------------------
      Code snippet:
      def foo(String[] a)

      { println a.length }

      def bar(Object[] a)

      { println a.length }

      def l = ["a","b"] as String[]
      foo(l)
      bar(l)

      Result:
      2
      1

      Expected result:
      2
      2

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            det Dirk Detering
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: