Skip to content
Browse files

SI-7432 Range.min should throw NoSuchElementException on empty range

For consistency, range.max and range.min should throw
NoSuchElementException on an empty range.
  • Loading branch information...
1 parent 1f2772a commit 357c2df4766a35089d91f92067b0cb87924f0ec9 @ihji ihji committed Apr 30, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/library/scala/collection/immutable/Range.scala
View
4 src/library/scala/collection/immutable/Range.scala
@@ -81,14 +81,14 @@ extends scala.collection.AbstractSeq[Int]
override def min[A1 >: Int](implicit ord: Ordering[A1]): Int =
if (ord eq Ordering.Int) {
- if (step > 0) start
+ if (step > 0) head
else last
} else super.min(ord)
override def max[A1 >: Int](implicit ord: Ordering[A1]): Int =
if (ord eq Ordering.Int) {
if (step > 0) last
- else start
+ else head
} else super.max(ord)
protected def copy(start: Int, end: Int, step: Int): Range = new Range(start, end, step)

0 comments on commit 357c2df

Please sign in to comment.
Something went wrong with that request. Please try again.