Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.7
-
None
Description
Calling next() on an ObjectRange iterator returns null when hasNext returns false. It should throw NoSuchElementException to adhere to the Iterator contract.
class ObjectRangeItrTest extends GroovyTestCase { void testItr() { def itr = ('a'..'b').iterator() assert itr.next() == 'a' assert itr.next() == 'b' assert !itr.hasNext() shouldFail(NoSuchElementException) { println itr.next() } } }
Attachments
Issue Links
- is duplicated by
-
GROOVY-7962 ObjectRange should throw an Exception intead of return null
- Closed
- is related to
-
GROOVY-7960 IntRange iterator returns null instead of NoSuchElementException
- Closed
- links to