Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what has changed about groovy class properties after the GINA book?

Tags:

groovy

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.

like image 836
JBT Avatar asked Nov 01 '22 16:11

JBT


1 Answers

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

like image 114
tim_yates Avatar answered Nov 15 '22 06:11

tim_yates