From: John Griffiths Date: 2009-05-15T00:38:29+09:00 Subject: Re: find previous & next in array > The safest is probably > > i = a.index('c') > > if i > predecessor = i > 0 ? a[i -1] : nil > successor = a[i + 1] # safe! > end > > Or as a variant > > i = a.index('c') and begin > predecessor = i > 0 ? a[i -1] : nil > successor = a[i + 1] # safe! > end > > Kind regards > > robert thanks Robert, i was trying to build up a little function to find the prev/next elements in an array, thanks to your help it's sorted; couldn't find a solution online. appreciate it all. John. -- Posted via http://www.ruby-forum.com/.