Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created May 24, 2011 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v6ak/988502 to your computer and use it in GitHub Desktop.
Save v6ak/988502 to your computer and use it in GitHub Desktop.
// 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