1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
scala> class Foo(val id: String) extends Dynamic { def _select_(name: String) = new Foo(id + "." + name) ; def _invoke_(name: String)(args: Any*) = { println(name + "(" + args.mkString(", ") + ")") ; this } }
defined class Foo

scala> val bob = new Foo("bob")
bob: Foo = Foo@4f19c297

scala> bob.tom.ding
dynatype: line2$object.$iw.$iw.bob._select_("tom")
dynatype: line2$object.$iw.$iw.bob._select_("tom")._select_("ding")
res0: Foo = Foo@7286a58a

scala> bob.tom.ding(1, 2, 3)
dynatype: line2$object.$iw.$iw.bob._select_("tom")
dynatype: line2$object.$iw.$iw.bob._select_("tom")._invoke_3("ding")
ding(1, 2, 3)
res1: Dynamic = Foo@1bd11b79