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

Inconsistent behavior between positive indices and negative indices.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0-JSR-5
    • 1.5
    • None
    • None
    • WinXP SP2

    Description

      ------------------------------------------------------------
      def list = [1,2,3,4,5,6,7,8,9]

      println list[99] // null is returned
      println list[-99] // throws java.lang.ArrayIndexOutOfBoundsException
      ------------------------------------------------------------
      Stack trace:
      Caught: java.lang.ArrayIndexOutOfBoundsException: Negative array index [-99] too large for array size 9
      at test.run(test.groovy:5)
      at test.main(test.groovy)

      To me, this seems to be inconsistent behavior for two similar expressions.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rmisek Ryan Misek
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: