From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2001-08-12T14:04:08+09:00 Subject: [ruby-talk:19574] Why not access control for instance and class variables? Maybe this is a silly question, but with all the recent talk about how subclasses can modify class variables and how that is possibly dangerous... why can't the access control functions (public,protected,private) be applied to class variables and instance variables as well? So that if you had: class Vehicle private @@number_of_Vehicles = 0 public def initialize @@number_of_Vehicles += 1 puts "there are now: "+@@number_of_Vehicles.to_s end end class Car < Vehicle def initialize super end def print_number_of_Vehicles p @@number_of_Vehicles #this would work since its a read-only access end def modify_number_of_vehicles(newValue) @@number_of_Vehicles = newValue #this would generate an access #exception end end The pickaxe book indicates that access control functions are applied to methods only. Phil