Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created March 17, 2011 08:08
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 yuroyoro/873993 to your computer and use it in GitHub Desktop.
Save yuroyoro/873993 to your computer and use it in GitHub Desktop.
Scalaのlazy valを強制的に再評価する(2.9)
class Nuclear{
lazy val radioactivity = {
println( "%sμSv/hだって " format util.Random.nextFloat * 400f)
"(((((((( ;゚Д゚))))))))ガクガクブルブルガタガタブルブル "* util.Random.nextInt(4)
}
}
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