From: Boby Selamet Hartono Date: 2009-05-14T12:48:03+09:00 Subject: Re: find previous & next in array --0016362837a8b46a8d0469d7315d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/5/14 John Griffiths > hi, anyone know how to do this? > > basically i've got an array of items > > a = ['a','b','c','d'] > > now given i can find the position of say 'c' using .index('c'), how do i > get the positions of the ones previous & next to it. > > a recursive routine would probably do it, but looking for something more > flash > > any ideas? > -- > Posted via http://www.ruby-forum.com/. > > a[a.index(:c)-1] or a[a.index(:c)+1]? -- Tidak ada yang lebih baik dari kembali ke asal Nothing can be better than back to the roots --0016362837a8b46a8d0469d7315d--