Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// inspired by http://thedailywtf.com/Articles/Disgruntled-Bomb-Java-Edition.aspx
import scala.util.Random
import java.lang.Integer
import scala.actors.Actor._
implicit def integerToInt(n: Integer) = n.intValue
val rand = new Random
val valueField = classOf[Integer].getDeclaredField("value")
valueField.setAccessible(true)
def munge(){
-127 to 127 foreach{ i =>
val k = rand.nextFloat*4-2
valueField.setInt(Integer.valueOf(i), (k*i round).toInt)
}
}
actor{
while(true){
munge()
}
}.start()
val a: Integer = 2
val b: Integer = 3
1 to 100000 foreach { _ =>
if(a < b){
print("<")
} else if (a > b){
print(">")
} else if (a == b){
print("==")
} else {
println("WTF?")
}
}
println()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment