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

A

Ace Mutha

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top