Skip to content

Instantly share code, notes, and snippets.

@tabdulradi
Last active November 19, 2016 21:24
Show Gist options
  • Save tabdulradi/b3ff116032f2eb16aedf077d8e5f8427 to your computer and use it in GitHub Desktop.
Save tabdulradi/b3ff116032f2eb16aedf077d8e5f8427 to your computer and use it in GitHub Desktop.
Scala Range.Long min/max bug
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
@tabdulradi
Copy link
Author

@tabdulradi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment