Friday, October 09, 2009

Subtle difference in access modifiers in java & ruby

Just going through basics of Ruby and realized there is a slight difference in the behavior for protected and private access modifiers. From java to Ruby access modification differences are (other then syntax)
1. In Ruby default access to instance messages is public. In java the default method visibility is package.
2. In Ruby private access can be done only internal to the instance i.e. not even from other instance of the other class. In java that is allowed. Pretty much because in Ruby access determination happens at runtime.