Last active
November 19, 2016 21:24
-
-
Save tabdulradi/b3ff116032f2eb16aedf077d8e5f8427 to your computer and use it in GitHub Desktop.
Scala Range.Long min/max bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> Range.Long.inclusive(111, 999, 1).max | |
res27: Long = 999 | |
scala> Range.Long.inclusive(111, 999, -1).max | |
res28: Long = 111 | |
scala> Range.Long.inclusive(111, 999, 1).min | |
res29: Long = 111 | |
scala> Range.Long.inclusive(111, 999, -1).min | |
java.util.NoSuchElementException | |
at scala.collection.LinearSeqOptimized$class.last(LinearSeqOptimized.scala:148) | |
at scala.collection.immutable.List.last(List.scala:84) | |
at scala.collection.immutable.NumericRange.last$lzycompute(NumericRange.scala:57) | |
at scala.collection.immutable.NumericRange.last(NumericRange.scala:56) | |
at scala.collection.immutable.NumericRange.min(NumericRange.scala:121) | |
... 33 elided | |
scala> Range.inclusive(111, 999, -1).max | |
java.util.NoSuchElementException: head of empty list | |
at scala.collection.immutable.Nil$.head(List.scala:420) | |
at scala.collection.immutable.Range.head(Range.scala:114) | |
at scala.collection.immutable.Range.max(Range.scala:125) | |
... 33 elided |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Fix