hashcode is called on the tuple. i have never seen the usage of x = name
in a for comprehension, btw.
is it a crippled pattern match like "val 1 = 2"? what does the compiler
turn it to?
variable in for expression:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at hstar.randomstuff.BigObject.hashCode(Hashcodetest.scala:12)
at scala.runtime.ScalaRunTime$._hashCode(ScalaRunTime.scala:193)
at scala.Tuple2.hashCode(Tuple2.scala:22)
at scala.collection.immutable.HashMap.elemHashCode(HashMap.scala:62)
at scala.collection.immutable.HashMap.computeHash(HashMap.scala:71)
at scala.collection.immutable.HashMap.$plus(HashMap.scala:53)
at scala.collection.immutable.HashMap.$plus(HashMap.scala:56)
at scala.collection.immutable.Map$Map4.updated(Map.scala:181)
at scala.collection.immutable.Map$Map4.$plus(Map.scala:182)
at scala.collection.immutable.Map$Map4.$plus(Map.scala:167)
at scala.collection.mutable.MapBuilder.$plus$eq(MapBuilder.scala:28)
at scala.collection.mutable.MapBuilder.$plus$eq(MapBuilder.scala:24)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
at
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
at
scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:176)
at
scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:345)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
at scala.collection.immutable.HashMap.map(HashMap.scala:36)
at
hstar.randomstuff.ForExpressionTest$delayedInit$body.apply(Hashcodetest.scala:27)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at
scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:60)
at scala.App$$anonfun$main$1.apply(App.scala:60)
at
scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at
scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:30)
at scala.App$class.main(App.scala:60)
at hstar.randomstuff.ForExpressionTest$.main(Hashcodetest.scala:17)
at hstar.randomstuff.ForExpressionTest.main(Hashcodetest.scala)
this fixes it:
for ((name, value) <- map; x <- List(name)) {
println(x)