Created
March 17, 2011 08:08
-
-
Save yuroyoro/873993 to your computer and use it in GitHub Desktop.
Scalaのlazy valを強制的に再評価する(2.9)
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
class Nuclear{ | |
lazy val radioactivity = { | |
println( "%sμSv/hだって " format util.Random.nextFloat * 400f) | |
"(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル "* util.Random.nextInt(4) | |
} | |
} |
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
public class Test { | |
public static void main(String[] args) { | |
Nuclear nuc1 = new Nuclear(); | |
System.out.println( nuc1.radioactivity() ); | |
System.out.println( nuc1.radioactivity() ); | |
nuc1.bitmap$0 = 0; | |
System.out.println( nuc1.radioactivity() ); | |
} | |
} | |
/** | |
ozaki@mbp $ java -cp $SCALA_HOME/lib/scala-library.jar:./ Test [~/sandbox/.../work/lazy] | |
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8 | |
157.7889μSv/hだって | |
(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル | |
(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル | |
61.489773μSv/hだって | |
(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment