From: Simen Edvardsen Date: 2006-08-26T05:07:13+09:00 Subject: Re: Collections of structured-data objects: what approach? On 8/25/06, Graham Wideman wrote: > Question: What does the keyword "self" do when sitting on a line by itself, > as in several of your methods? > Ruby returns the last value of a method. self on a line by itself returns self. Graham Wideman wrote: >> You can get away with just using an Array for almost all of this. >> >> a = [{:a => 1, :b => 2}, {:c => 4, :d => 5}] >> a[1] # => {:c=>4, :d=>5} >> a << {:e => 6, :f => 7} >> # => [{:b=>2, :a=>1}, {:c=>4, :d=>5}, {:e=>6, :f=>7}] >> a.select {|x| x[:c] == 4} # => [{:c=>4, :d=>5}] >> >> b = [1,2,3,4] >> b.insert(2,5) # => [1, 2, 5, 3, 4] > >Now THAT's the set of examples I needed, and that should be in the major >Ruby docs. It is in the main Ruby docs. It's spread between the methods in use, because we couldn't anticipate every single combination of methods you might need to use and document them all in one place. -- - Simen