You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.IllegalArgumentException: requirement failed
at scala.Predef$.require(Predef.scala:204)
at scala.collection.mutable.BitSet.add(BitSet.scala:74)
at scala.collection.mutable.BitSet.$plus$eq(BitSet.scala:92)
at scala.Enumeration$ValueSet$$anon$1.$plus$eq(Enumeration.scala:283)
at scala.Enumeration$ValueSet$$anon$1.$plus$eq(Enumeration.scala:281)
at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:48)
at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:48)
at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:107)
at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:107)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:204)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
at scala.collection.mutable.HashMap$$anon$2.foreach(HashMap.scala:107)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.Enumeration$ValueSet$$anon$1.$plus$plus$eq(Enumeration.scala:281)
at scala.Enumeration.values(Enumeration.scala:93)
at Test$.main(t5588.scala:10)
at Test.main(t5588.scala)
The text was updated successfully, but these errors were encountered:
@ViniciusMiana said:
This is actually a BitSet problem. The example works on 2.9, because it did not use BitSet internally.
If you try:
scala> val b = new mutable.BitSet
scala> b+= 2000000000
you will get either:
res0: b.type = BitSet()
or
java.lang.OutOfMemoryError: Java heap space
Now when you use number like 2000000000 and -2000000000, since they are converted to a positive integer to store in the BitSet, you get an int overflow.
A simple example of enumeration
produces (as expected):
Add another value to the enumeration:
produces:
But this gets even better when you add
because it gives you
The text was updated successfully, but these errors were encountered: