From: Stefano Crocco Date: 2008-04-14T20:09:08+09:00 Subject: Re: Problem in array On Monday 14 April 2008, Pranjal Jain wrote: > Can anyone suggest me the solution for this? Use a valid index and make sure the element of the array you're testing is not nil. Ruby is complaining that you called the >= method on nil, which doesn't have such a method. Since you're using the >= operator on the value returned by p[x], this may mean two things: 1) x >= p.size: An array of size n contains n elements, with index from 0 to n-1. If you try accessing an element with an index greater than that, Array#[] will return nil. 2) x < p.size and p[x] == nil: even if the index is less than the size of the array, the array can contain nil elements. For example [1,2,nil,3] has nil as the third entry, so calling [1,2,nil,3][2] will return nil. Since you didn't give any information on how p is obtained, I can't give you a more specific advice. If this doesn't help you and you want more suggestions, please give us more information. Stefano