On Thu, Nov 22, 2012 at 1:52 PM, Steve Tucknott <[email protected]> wrote:
> My todo list has a list array. I want to load the list array with the > item objects and am using the << operator as: > > @list << item_rec > > This seems to work ok, and my array goes from 0 length to 1. But, I had > hoped then to access the record fields via 'list', ie: > list[0].action > but when I try to access the 'list[n].action' I seem to have nil in the > field(s),although looking at 'list' in total seems to show the data. > List is ([#<TodoItem:0x8379f30 @item_rec=#<OpenStruct done=false, > action="1", name="hgafafgafgagaf">>]) With that structure you rather need to do list[0].item_rec.action don't you? Can you share the code of class TodoItem? > Is it because I have an array of 'objects' - ie 'list' now contains a > single element of class 'TodoItem'? If so, how do I access the > 'item_rec' sub object of 'list'? See above. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
