From: "Richard D." Date: 2012-10-02T11:19:45+09:00 Subject: how to read arrary with an array Hello. I believe this is basic question, but I'm just starting to learn programming and choose Ruby to learn from. I grabbed Chris Pine's book Learn to Program to read, try, and learn from. Anyway, the book had a lesson on creating a table contents using arrays. Below is his less advance solution he gave. For the most part I get it. The problem, I don't understand how to read the arrary within an array, or more how the pc reads it. I think that also leads to why I don't understand the variables being created later as well. I tried looking around here, and google, but I'm getting results beyond the lesson and my understanding. Below is the program and my notes. Thanks in advance--Rich. # table of contents using arrays title = 'Table of Contents' chapters = [['Getting Started', 1], ['Numbers', 9], ['Letters', 13]] # array within an array. # don't understand how to read puts title.center(50) puts chap_num = 1 chapters.each do |chap| name = chap[0] # don't undestand chap [0] and chap [1] reference page = chap[1] # assuming where in master array to pull data beginning = 'Chapter ' + chap_num.to_s + ': ' + name ending = 'page ' + page.to_s puts beginning.ljust(30) + ending.rjust(20) chap_num = chap_num + 1 end -- Posted via http://www.ruby-forum.com/.