Thread error "undefined method `keys' for nil:NilClass"

Discussion in 'Ruby' started by Ace Mutha, Oct 29, 2009.

  1. Ace Mutha

    Ace Mutha Guest

    Hi all I have this prog taken from a book.

    require 'net/http'

    pages = ["www.rubycentral.com", "www.awl.com", "www.davidecasale.com"]


    threads = []


    pages.each do |page|
    threads << Thread.new(page) { |myPage|


    h = Net::HTTP.new(myPage, 80)
    puts "Fetching: #{myPage}"
    resp, data = h.get('/', nil )
    puts "Got #{myPage}: #{resp.message}"
    }
    end

    but when i run it It gives me this error.

    /usr/local/lib/ruby/1.9.1/net/http.rb:809:in `get': undefined method
    `keys' for nil:NilClass (NoMethodError) from Threads.rb:19:in `block (2
    levels) in <main>'

    It's weird because it's working on ruby 1.8.7
    --
    Posted via http://www.ruby-forum.com/.
    Ace Mutha, Oct 29, 2009
    #1
    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. Charles A. Lackman

    Terminating a thread from the main thread

    Charles A. Lackman, Dec 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,541
    Herfried K. Wagner [MVP]
    Dec 9, 2004
  2. pawo
    Replies:
    0
    Views:
    490
  3. Stephen Miller
    Replies:
    3
    Views:
    3,966
    Stephen Miller
    Jul 2, 2004
  4. Johanna
    Replies:
    0
    Views:
    603
    Johanna
    Oct 13, 2004
  5. vincent wehren
    Replies:
    0
    Views:
    433
    vincent wehren
    Dec 11, 2003
Loading...

Share This Page