_select_ and _invoke_ behave like a Ruby missing_method . When a method is called in a dynamic instance that does not implement the method, _select_ or _invoke_ is _select_ _invoke_ . These two methods can be implemented as you wish.
In your example, they use reflection to invoke the actual implementation of member x . For instance:
scala> val s: Dynamic = "Hello, world!" s: Dynamic = Dynamic(Hello, world!) scala> s.toLowerCase dynatype: line8$object.$iw.$iw.s._select_("toLowerCase") res2: Dynamic = Dynamic(hello, world!)
The toLowerCase method toLowerCase not defined in s . Thus, the _select_ method _select_ called with the argument "toLowerCase" . The dynamic engine then calls x.toLowerCase with reflection and completes the result in a new dynamic instance.
_select_ is called for any method with no arguments, and _invoke_ is called for any method with arguments.
source share