From: bbiker Date: 2009-08-04T08:40:06+09:00 Subject: Re: Inconsistency in Array#[] On Aug 3, 4:38 am, Harry Kakueki wrote: > On Mon, Aug 3, 2009 at 5:17 PM, Bertram Scharpf wrote: > > Hi, > > > Am Montag, 03. Aug 2009, 09:11:11 +0900 schrieb Bertram Scharpf: > >> Am Montag, 03. Aug 2009, 05:50:10 +0900 schrieb Wojciech Piekutowski: > >> >   a = [1,2,3,4,5] > > >> I would even prefer a behaviour like this: > > >>   a[3,-3]    #=> [4,3,2] > > >> This would be the least surprise to me. > > > Sorry! The least surprise of course would be > > >  a[3,-3]    #=> [3,2,1] > > > Bertram > > > -- > > Bertram Scharpf > > Stuttgart, Deutschland/Germany > >http://www.bertram-scharpf.de > > Really? > > a = [1,2,3,4,5] > p a[3,2] #=> [4, 5] > > #p a[3,-3] #=> [4,3,2] > #a[start,length] > > This seems least surprising to me. > > Harry > > -- > A Look into Japanese Ruby List in Englishhttp://www.kakueki.com/ruby/list.html I'm sorry to butt in, but your getting exactly what you ask for but you expecting otherwise! a[x, y] means starting at element x give me up to y elements a = [1.2.3.4,5] a[-3,3] => [3,4,5] a[-3,4] => [3.4,5] a[-3,0] => [] a[3,-3] => # there is no such thing -3 elements therefore it returns nil