Code Snippets

require 'net/http'

urls = %w[https://example.com https://api.github.com/zen https://ruby-lang.org]

threads = urls.map do |u|
  Thread.new do
    res = Net::HTTP.get_response(URI(u))
    "#{u} -> #{res.code}"
  end
end

threads.each { |t| puts t.value }