Is there a Ruby library version problem with my ISP ?

Discussion in 'Ruby' started by Josselin, Dec 20, 2006.

  1. Josselin

    Josselin Guest

    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

    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

    joss
    Josselin, Dec 20, 2006
    #1
    1. Advertising

  2. 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
    >
    > 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.

    <code>
    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
    </code>

    It will assign an asterisk ('*') to letter when there are no non-zero
    items in nb_cities_alphabet, which help with debugging.

    Regards, Morton
    Morton Goldberg, Dec 21, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fred Exley
    Replies:
    3
    Views:
    359
    Bruce Barker
    Mar 21, 2006
  2. V Green
    Replies:
    0
    Views:
    808
    V Green
    Feb 5, 2008
  3. PA Bear [MS MVP]
    Replies:
    0
    Views:
    908
    PA Bear [MS MVP]
    Feb 5, 2008
  4. Une bévue

    known isp running ruby

    Une bévue, Mar 15, 2006, in forum: Ruby
    Replies:
    4
    Views:
    124
    Une bévue
    Mar 15, 2006
  5. SpringFlowers AutumnMoon

    Using Ruby on a generic ISP

    SpringFlowers AutumnMoon, Oct 6, 2007, in forum: Ruby
    Replies:
    2
    Views:
    147
    John Joyce
    Oct 7, 2007
Loading...

Share This Page