On Tue, Aug 4, 2009 at 8:40 AM, bbiker<renard / nc.rr.com> wrote: > On Aug 3, 4:38 am, Harry Kakueki <list.p... / gmail.com> wrote: >> On Mon, Aug 3, 2009 at 5:17 PM, Bertram Scharpf<li... / bertram-scharpf.de> 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 > > I am not expecting otherwise. I realize it does not work, and I understand why. That is why it is commented out. It was suggested that this type of behavior would be nice. If it did work, I would expect it to work that way. Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html