Tutorial by Examples

This: class Foo extends Dynamic { // Expressions are only rewritten to use Dynamic if they are not already valid // Therefore foo.realField will not use select/updateDynamic var realField: Int = 5 // Called for expressions of the type foo.field def selectDynamic(fieldName: String) = ...
This: class Villain(val minions: Map[String, Minion]) extends Dynamic { def applyDynamic(name: String)(jobs: Task*) = jobs.foreach(minions(name).do) def applyDynamicNamed(name: String)(jobs: (String, Task)*) = jobs.foreach { // If a parameter does not have a name, and is simply given, th...
Slightly counterintuitively (but also the only sane way to make it work), this: val dyn: Dynamic = ??? dyn.x(y) = z is equivalent to: dyn.selectDynamic("x").update(y, z) while dyn.x(y) is still dyn.applyDynamic("x")(y) It is important to be aware of this, or else...

Page 1 of 1