From: Siep Korteling Date: 2008-02-10T09:08:53+09:00 Subject: Re: Recursive array bug? Justin Collins wrote: > Siep Korteling wrote: >> error. Investigating my unflattened array I found something strange. >> >> 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 Yes it does. I had to think real hard about it. With a[0][0] I expected to get a value from a matrix (but there is no matrix, give me the blue pill please), when I'm actually calling a method from a string. Why it returns 97 is beyond me at this moment, but it's not relevant. Duck typing fooled me, I guess. Regards and thank you, Siep -- Posted via http://www.ruby-forum.com/.