juan_gandhi: (Default)
2017-09-21 03:01 pm
Entry tags:

just found a bug...

In spark.core, RNG, specifically, normal distribution RNG.

It caches values (randomly). Now try to reseed. 
juan_gandhi: (VP)
2015-02-18 09:57 am
Entry tags:

funny error in Scala code

val text = "\n\n\nHEADER\n\ncontent\n\n"
val cleanedup = text.dropWhile("\n"==)


The bug comes from the universality of jvm equality, I'd say.
juan_gandhi: (Default)
2012-10-18 10:27 am
Entry tags:

scala fun

(from scala-user)

Can someone tell me whether this "gotcha" is type-unsafe or am I just not realizing something? This bit me in production code today (via java interop).
scala> def x: java.math.BigDecimal = null
x: java.math.BigDecimal

scala> def y = Option[BigDecimal](x) orElse Option[BigDecimal](x)
y: Option[BigDecimal]

scala> for (z <- y) println(z)
java.lang.NullPointerException


Year 2020:
...
java.lang.IllegalArgumentException: null value for BigDecimal
  at scala.math.BigDecimal.(BigDecimal.scala:406)
  at scala.math.BigDecimal$.apply(BigDecimal.scala:335)
  at scala.math.BigDecimal$.apply(BigDecimal.scala:332)
  at scala.math.BigDecimal$.javaBigDecimal2bigDecimal(BigDecimal.scala:347)
  at .y(:12)
  ... 28 elided