From: Sean Middleditch Date: 2001-08-08T03:11:51+09:00 Subject: [ruby-talk:19306] Virtual list For starts, I'm new to Ruby still, forgive me naivette. (Is that even a word?) I'm mostly a C++ programmer, so my terminology might be a little off towards that direction.. ^,^ If I have a class Object (in C++, called AMObject in Ruby), and it has two lists in it - a list of attributes (properties of an item), and containers (difference types of containers that store more Objects), how can I make a clean interface to traversing these objects in Ruby? In C++ the tree is like: Object (class object) attributes (class list) obj_attr obj_attr ... containers (class list) container container ... Something like this in Ruby would be nice: obj.attrs.for_each { |a| whatever... } How do I go about making a clean class for "attrs?" I'd also like to have the ability to append/remove entries from the list, so I know there will be a bit of work involved. The class would have to store a reference to the parent Object. But how would I go about generating such a class? Preferrably in a generic way so that all types of objects could be stored within. There, I think that was a ludicrous amount of information for such a simple question. I hope I made that clear enough... Sean Etc.