From: Drew Olson Date: 2007-03-13T00:50:59+09:00 Subject: Re: Representing a complex object chandra shekhar G wrote: > Hi > > we are facing trouble in implementing a complex object in ruby, > like say we have a class B which has a member int and a member string, > we have to implement a class A whose members are an array of objects of > B > how is it done, pls do respond. > > Regards > chandra shekhar G Do you really find this to be "complex"? It seems relatively straight forward... class B def initialize(my_int,my_string) @my_int = my_int @my_string = my_string end end class A def initialize @my_objects = [] end def add_item(item) @my_objects << item end end my_b = B.new(10,"foo") my_a = A.new my_a.add_item my_b -- Posted via http://www.ruby-forum.com/.