Anyone else surprised this code works?
class Book {
private title
}
def book = new Book()
book.title = 'Principle of Least Surprise'
assert book.title == 'Principle of Least Surprise'
Since title is private, shouldn’t I have to access it via getters and setters?
See http://jira.codehaus.org/browse/GROOVY-1591.
Comment by Jeff Brown — February 28, 2007 @ 1:17 pm
At least it’s recognized as critical
Comment by Jeff W. — February 28, 2007 @ 8:18 pm
Read page 70 in “Groovy Recipies”; “Gotcha: Groovy Ignores the Private Modifier
Comment by stigl — June 20, 2008 @ 2:03 am