Skip to end of metadata
Go to start of metadata

Last metaprogramming feature we'll cover today: runtime mixins. @Mixin allowed you to mixin new behavior to classes you owned and were designing. But you could not mixin anything to types you didn't own. Runtime mixins propose to fill that gap by letting you add a mixin on any type at runtime. If we think again about our example of vehicles with some mixed-in capabilities, if we didn't own James Bond's vehicle and give it some diving ability, we could use this mechanism:

One or more mixins can be passed as argument to the static mixin() method added by Groovy on Class.

  • No labels