diff options
-rw-r--r-- | src/library/scala/collection/immutable/Range.scala | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 0c24d17c15..2e56750115 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -81,8 +81,7 @@ extends scala.collection.AbstractSeq[Int] || (start == end && !isInclusive) ) - @deprecated("this method will be made private, use `length` instead", "2.11.0") - final val numRangeElements: Int = { + private val numRangeElements: Int = { if (step == 0) throw new IllegalArgumentException("step cannot be 0.") else if (isEmpty) 0 else { @@ -92,21 +91,16 @@ extends scala.collection.AbstractSeq[Int] } } - @deprecated("this method will be made private, use `last` instead", "2.11.0") - final val lastElement = - if (isEmpty) start - step - else step match { - case 1 => if (isInclusive) end else end-1 - case -1 => if (isInclusive) end else end+1 - case _ => - val remainder = (gap % step).toInt - if (remainder != 0) end - remainder - else if (isInclusive) end - else end - step - } - - @deprecated("this method will be made private", "2.11.0") - final val terminalElement = lastElement + step + // This field has a sensible value only for non-empty ranges + private val lastElement = step match { + case 1 => if (isInclusive) end else end-1 + case -1 => if (isInclusive) end else end+1 + case _ => + val remainder = (gap % step).toInt + if (remainder != 0) end - remainder + else if (isInclusive) end + else end - step + } /** The last element of this range. This method will return the correct value * even if there are too many elements to iterate over. |