| Excerpt | ||
|---|---|---|
| ||
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")
|