From: Leonard Chin Date: 2007-06-01T18:29:31+09:00 Subject: Re: How to specify access modifers for variables???? On 6/1/07, raja wrote: > and which in fact are "methods", thus IS IT IMPOSSIBLE TO DECLARE ACCESS > MODIFIERS FOR VARIABLES ? In a word, no. Short answer: Access modifiers only apply to methods. Instance variables can only be accessed through methods, and cannot be accessed without methods. Hence, the concept of visibility does not exist for instance variables in ruby. Long answer: Although they are very similar concepts, please remember that there is a distinction between instance variables and an attributes. Although they can refer to the same "thing", instance variables are the objects internal state, whereas attributes are (effectively) the subset of the instance variables which are exposed to the outside world. If you are accustomed to languages where you can access the attributes of an object without methods (such as in Java), it can be a little confusing. In ruby, you have to use a method to access internal state. All instance variables are accessed via accessor methods, which conveniently have the same name as the variable. As a result, you cannot declare access modifiers for instance variables because the concept of visibility (private, protected, public) only exists for methods, and not instance variables.