From: Steve Tucknott Date: 2012-11-22T21:52:39+09:00 Subject: Arrays with records as objects I am completely new to Ruby. I have been reading through the tutorials and trying to build an example set. One example I saw was a basic todo list. I have then taken that example and tried to modify it. What I want is a file with two fields, action no, and text. That file is read, and from each entry in the file, an 'item' object is created that contains a record structure of status, action no and text. That 'item' object is then loaded into a 'todo list' and the list displayed on screen for the user to mark the completed actions. I have then two objects - the 'todo list' and the 'todo item'. The item has an initializer that takes the delimited file line (format action no<<>>text) and splits that line into a structure that also has a status. 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 ([#>]) 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'? Does any of that make sense? -- Posted via http://www.ruby-forum.com/.