Ernest Ellingson wrote: > > At 03:27 2/18/2001 +0900, you wrote: > > >a = "FooBar" > >b = a.split(//) > >b[6,2] #=> [] > >a[6,2] #=> nil > > > >anyone knows why this last one returns nil instead of "" (empty string) ? > > > >matju > > a[6] doesn't exist thus a[6,2] doesn't exist, thus Ruby says "Ain't no such > thing" Yes, but b[6] doesn't exist, either, so why should b[6,2] exist? ==== irb session irb(main):001:0> a = "FooBar" "FooBar" irb(main):002:0> b = a.split(//) ["F", "o", "o", "B", "a", "r"] irb(main):003:0> b[6] nil irb(main):004:0> b[6,2] [] irb(main):005:0> b[7] nil irb(main):006:0> b[7,2] nil ===== So it is certainly strange... Guy N. Hurst -- HurstLinks Web Development http://www.hurstlinks.com/ Norfolk, VA 23510 (757)623-9688 FAX 623-0433 PHP/MySQL - Ruby/Perl - HTML/Javascript