Dave Thomas wrote:
> ...
> True 'nuff, although
> 
>    b = [1,2,3]
>    a[1,0] = [b]
> 
> Does what you'd want.
> 

hmm.


irb(main):001:0> a=[1,2,3]
[1, 2, 3]
irb(main):002:0> a[1,0]=[a]
[[1, [...], 2, 3]]
irb(main):003:0> a
[1, [...], 2, 3]
irb(main):004:0> a[1]
[1, [...], 2, 3]
irb(main):005:0> a[1][1]
[1, [...], 2, 3]
irb(main):006:0> a[1][1][1][1]
[1, [...], 2, 3]
irb(main):007:0> a[1][1,1]
[[1, [...], 2, 3]]
irb(main):008:0> a[1,1][0][1,1]
[[1, [...], 2, 3]]
irb(main):009:0> a[1][1][1][1][1][1][1][1][1][1]
[1, [...], 2, 3]
irb(main):010:0> a.flatten
ArgumentError: tryed to flatten recursive array
(irb):12:in `flatten'
(irb):12:in `irb_binding'
irb(main):013:0> a[1][1][1][1][0]
1
irb(main):014:0>

This is certainly interesting  :-)

I didn't realize Ruby could handle a recursive array

(ps 'tryed' should be 'tried')

> Not being able to extend at the end is a problem, but then there's
> always #push
> 

Yes, and also +=

But that leaves something to be desired, nonetheless.

> However, can I make a suggestion?
> 
> Let's not implement this in C code, but in a Ruby-language module. Let
> people use it that way and get experience with it before making code
> changes in the interpreter.
>

That may be fine for #insert, but what about changing the semantics
of negative position?
 


Guy N. Hurst

-- 
HurstLinks Web Development    http://www.hurstlinks.com/
Norfolk, VA - (757)623-9688
PHP/MySQL - Ruby/Perl - HTML/Javascript