From: Oliver Saunders Date: 2008-05-06T09:04:28+09:00 Subject: Re: Extending Array and assigning to self yermej wrote: > I would just use Array's own methods. E.g.: > class Pages < Array > def import(file, page_delimiter = ' ') > self.clear > self.concat file.read.split.page_delimiter > end > end > > I'm not sure if Array#concat is the best choice here (for some > definition of best), but it'll work. Fantastic yermej. I didn't know about that concat method. Next point: What if I have a similar problem with strings? I'd like to achieve this: # is a string x = ValueChangeString.new 'foo' #=> 'foo' # has all the methods of string already x.length #=> 3 # But also has methods that completely alter the string's value # whilst remaining the same object x.change_value! #=> 'bar' -- Posted via http://www.ruby-forum.com/.