Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


Adding or overriding static methods

ExpandoMetaClass - Adding static methods

Static methods can also be added using the same technique as instance methods with the addition of the "static" qualifier before the method name:

Code Block
class Book {
   String title

Book.metaClass.static.create << { String title -> new Book(title:title) }

def b = Book.create("The Stand")