I am reading the Groovy in Action (GINA) book. In chapter 9, there is this listing:
class MyClass {
def first = 1
def getSecond() { first * 2 }
public third = 3
}
obj = new MyClass()
keys = ['first', 'second', 'third', 'class', 'metaClass']
assert obj.properties.keySet() == new HashSet( keys ) // fail
However, the following assert is actually the right one:
keys = ['first', 'second', 'class']
assert obj.properties.keySet() == new HashSet( keys )
So, what has changed about groovy class properties after the GINA book? Thank you.
From the forum for the book, it looks like that bit was an error, or something changed and no one is sure what.
You're better getting access to the MEAP second edition of the book as this covers groovy 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With