Created
March 26, 2011 06:51
-
-
Save yuroyoro/888082 to your computer and use it in GitHub Desktop.
scala2.9.0.RC1でのDynamicのテスト
This file contains hidden or 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
[0]ozaki@mbp $ scala -Xexperimental [~/sandbox/scala/work][0] | |
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8 | |
Welcome to Scala version 2.9.0.RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> trait DI extends Dynamic { | |
| def applyDynamic(name:String)(args:Any*):Any = println("Hello, %s %s" format( name, args.mkString("[", ", ", "]"))) | |
| } | |
defined trait DI | |
scala> class Hello | |
defined class Hello | |
scala> val hello = new Hello with DI | |
hello: Hello with DI = $anon$1@17ac9cff | |
scala> hello.world( "高速増殖炉もんじゅ") | |
dynatype: $line3.$read.$iw.$iw.hello.applyDynamic("world") | |
Hello, world [高速増殖炉もんじゅ] | |
res0: Any = () | |
scala> hello.goodbye("社会的に","デッドエンド") | |
dynatype: $line3.$read.$iw.$iw.hello.applyDynamic("goodbye") | |
Hello, goodbye [社会的に, デッドエンド] | |
res1: Any = () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment