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

getAt(EmptyRange) not called when passing an EmptyRange to getAt(Collection)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6
    • 2.1.0-rc-2, 2.1.0
    • None
    • None

    Description

      Basically, this is an inconsistency of List#getAt(Collection). When its parameters are integer indexes and non-empty ranges, it works as expected. But when an EmptyRange is passed to it, it doesn't behave like List#getAt(EmptyRange):

      def list = [1, 2, 3]
      assert list[3..<3] == []        // This works
      assert list[0, 2..<3] == [1, 3] // This works too
      assert list[0, 3..<3] == [1]    // But this throws IndexOutOfBoundsException: toIndex = 4
      

      Attachments

        1. emptyRangeOnGetAt.groovy
          0.2 kB
          Demian Ferreiro

        Activity

          People

            paulk Paul King
            epidemian Demian Ferreiro
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: