From: Morton Goldberg Date: 2006-12-21T16:30:53+09:00 Subject: Re: Is there a Ruby library version problem with my ISP ? On Dec 20, 2006, at 5:30 PM, Josselin wrote: > I am running locally without any problem the following simple > statement (detect first non-zero value...) > > nb_cities_alphabet = [7, 21, 20, 1, 4, 1, 18, 3, 5, 1, 4, 48, 21, > 8, 0, 31, 6, 10, 47, 7, 0, 1, 0, 0, 0, 0] > > i = nb_cities_alphabet.index(nb_cities_alphabet.detect {|x| x > > 0}) > letter = ('A'..'Z').to_a[i] > > but when running it with my ISP I get the error message : > > NoMethodError : undefined method `detect' for false:FalseClass > > any idea why this error ? and why I don't get it locally ? > > if it's actually a lib problem... any trick to replace it > thanks a lot I don't have any idea about what's going wrong with your server, but you might try the following code. It's a little more robust and efficient than what you are using now. nb_cities_alphabet = [7, 21, 20, 1, 4, 1, 18, 3, 5, 1, 4, 48, 21, 8, 0, 31, 6, 10, 47, 7, 0, 1, 0, 0, 0, 0] i = ?* - ?A nb_cities_alphabet.each_with_index do |e, k| if e > 0 i = k break end end letter = (i + ?A).chr It will assign an asterisk ('*') to letter when there are no non-zero items in nb_cities_alphabet, which help with debugging. Regards, Morton