On Jul 11, 2:27 pm, Pieter Mans <tybr... / gmail.com> wrote: > I'm trying to create a map datatype (a glorified matrix, really). It > basically works on having a bunch of nested arrays. The idea is that I > pass an X and a Y coord as arguments and then it returns the Xth element > in the Yth array. > > The problem is that I cant seem to get a specific value from a nested > array. > > For example, this works: > irb> array[2] > => [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] > > But this doesn't seem to: > irb> array[2[2]] > => [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] > > I'm pretty sure I'm just getting the syntax wrong. > > -- > Posted viahttp://www.ruby-forum.com/. 035:0> a = [[1,2],[3,4]] => [[1, 2], [3, 4]] 036:0> a[1] => [3, 4] 037:0> a[1][0] => 3 Array#[] is just a method, so when you need to do it in succession, you just add it do the end. Just like " hello ".strip.upcase HTH, Chris