From: Justin Collins Date: 2008-02-10T07:54:34+09:00 Subject: Re: Recursive array bug? Siep Korteling wrote: > I've just reinvented the recursive array. > > a = ["a rose is "] > a << a > > Expecting the end of the world, or at least my ruby session, I did: > > a.flatten! > > But flatten! was just waiting for idiots like me and returned a polite > error. Investigating my unflattened array I found something strange. > > p a[1][1][1][0] > =>a rose is > > p a[0] > => a rose is > > p a[0][0] > =>97 > Huh? I expected nil. > > p a[0][0][0] > =>1 > and it keeps returning 1's as far as I can see. Is this a bug or am I > just being silly? > > Regards, > > Siep > Does this help? irb(main):001:0> a = [ "array" ] => ["array"] irb(main):002:0> a << a => ["array", [...]] irb(main):003:0> a[0] # This is Array#[] => "array" irb(main):004:0> a[0][0] # This is String#[] => 97 irb(main):005:0> a[0][0][0] # This is Fixnum#[] => 1 irb(main):006:0> a[0][0][0][0][0] # This is also Fixnum#[] => 1 -Justin