Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Private method in groovy is not private

Tags:

class A {     private def sayHello() {        println "Anish"     }   }   def a_obj = new A()  a_obj.sayHello() 

output : Anish

Is there any way to protect sayHello() in groovy or am I missing something?

like image 360
anish Avatar asked Oct 21 '11 16:10

anish


2 Answers

There is defect on that in Groovy issue tracking system and that defect is still open.

like image 168
Andrey Adamovich Avatar answered Oct 19 '22 18:10

Andrey Adamovich


Searching for [groovy] private reveals:

groovy call private method in Java super class

What does 'private' mean in Groovy?

How to define private getter method in Groovy Bean?

It's not clear if it is a bug or by design, but it is going to get looked at again in Groovy 2.0

like image 34
tim_yates Avatar answered Oct 19 '22 16:10

tim_yates