From: Meino Christian Cramer Date: 2003-08-17T00:29:34+09:00 Subject: Newbie Q: Data encapsulation with Ruby Hi, as a beginner in C++ I learned that one advantage of OOP over the procedural programming is data hiding and encapsulation. In C++ this is achieved via the public:, protected: and private: keywords. As I currently (try to) understand, Ruby does it somehow different. class A def initializer( k_a ) @a = k_a end end will declare a class A with a "totally private" attribute "a", which only can be accessed vie get/set-combos. Now I found (for me astonishling) two keywords: attr_reader: and attr_writer: which (seems to) totally "inifiltrate" the principle of data hiding and encapsulation. PLEASE! Dont misundertstood my words as any kind of critism on Ruby !!! I only want to express my current (mis)understanding of that what I try to understand. What is the secret behind attr_reader and attr_writer and how do they support OOP? Kind regards, Meino