From: 7stud -- Date: 2012-10-03T03:52:09+09:00 Subject: Re: how to read arrary with an array > array2 = ['a',[1,2],'x'] > a is slot1-0-0, 1 is 1-0, 2 is 1-1, and x is 2-0 No. Your array has 3 elements (remember commas separate the elements of an array) The first element of your array is at index position 0, and it is the string 'a'. The second element of your array is at index position 1, and it is the array [1, 2] The third element of your array is at index position 2, and it is the string 'x'. Once you get a reference to any of those items, you can do whatever that item's class allows you to do to the item. So for instance, for either of the strings you can call the capitalize() method--but you can't call capitalize() on the array. Where you seem to be confused is that the String class also allows you to call the method [] on a String, so a String acts like an array in that respect. As a result, you can do this: data = [ 'hello', 'world' ] data.each do |string| puts string puts string[2] end --output:-- hello l world r But look what happens here: string = 'a' p string[1] --output:-- nil That's because the String only has a character at position 0, and position 1 is beyond the end of the String. -- Posted via http://www.ruby-forum.com/.