From: 7stud -- Date: 2012-10-02T12:37:56+09:00 Subject: Re: how to read arrary with an array > don't undestand chap [0] and chap [1] reference If you are confused, it is the author's fault for choosing confusing variable names. If the variable names were descriptive, the code would be self explanatory. colors = ['red', 'black', 'yellow'] colors.each do |color| puts "The current color is: #{color}" end --output:-- The current color is: red The current color is: black The current color is: yellow array_of_arrays = [ [10, 20, 30], ['a', 'b', 'c', 'd'], ['hello', 'goodbye'] ] array_of_arrays.each do |sub_array| p sub_array end --output:-- [10, 20, 30] ["a", "b", "c", "d"] ["hello", "goodbye"] array_of_arrays.each do |sub_array| puts sub_array[0] end --output:-- 10 a hello array_of_arrays.each do |chapter| puts chapter[0] end --output:-- 10 a hello zebras = [ [10, 20, 30], ['a', 'b', 'c', 'd'], ['hello', 'goodbye'] ] zebras.each do |elephant| p elephant[0] end --output:-- 10 "a" "hello" If you are confused about what is contained in a variable, go ahead and print it out, e.g. zebras.each do |elephant| #what the #@$#@ is elephant referring to?? p elephant #add this line to see what the heck elephant is all about p elephant[0] end -- Posted via http://www.ruby-forum.com/.