Created
May 24, 2011 10:41
-
-
Save v6ak/988502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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