Groovy Bar & Grill

February 26, 2007

Groovy Principle of Least Surprise Violation?

Filed under: Groovy Bar — jawild59 @ 9:21 pm

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?

Blog at WordPress.com.