From: Todd Date: 2005-12-05T11:02:50+09:00 Subject: Re: Deleting object inn array, if... Henrik Orm�sen wrote: > Thanks for the fast replay's, I'm impressed :-). > > Her is my DB thing: > > class Item > attr_reader :body > > FAKE_DATABASE = [] > > def initialize(body) > @body = body > end > def add > FAKE_DATABASE.unshift(self) > end > def self.find_recent > FAKE_DATABASE > end > def del > FAKE_DATABASE.delete_if {|x| x.body == @body } > end > end > > > - Henrik Sounds maybe you are trying to do something like: class Item attr_reader :body @@db = [] def initialize( body ) @body=body end def add() unshift.self end def recent() @@db end def del @@db.delete_if { |x| x.body==@body } end => nil a = Item.new "a" => # b = Item.new "b" => # a.add => [#] b.add => [#, #] a.recent => same thing as above b.recent => same thing as above a.add => [#, #] note there are 2 "a" objects in the same db, you probably don't want this, so will have to change your add method accordingly a.recent == b.recent => true a.del => [#] b.del => [] a.recent == b.recent => true At least that's the direction you look like you are headed. hth, Todd