Is there anything equivalent to Groovy’s remarkable SomeClass.metaClass.getProperty function in scala? This would be very helpful in making domain specific languages. For example, I could then say: val x = SomeClass(); x.arbitraryPropertyName rather than x.get("arbitraryPropertyName") or x("arbitraryPropertyName").
Is there anything equivalent to Groovy’s remarkable SomeClass.metaClass.getProperty function in scala? This would be
Share
From your description, this feature sounds like Scala’s
Dynamic. From the Scaladoc,That is, if your class extends
Dynamic, then calls of the formx.arbitraryPropertyNameget translated tox.applyDynamic("arbitraryPropertyName"), and of course you get to define the behavior ofapplyDynamic.