def log_then_get(url, context) puts "Requesting #{url}..." get(url, context) end def get(uri, context) response = Net::HTTP.get(uri) puts caller(0).join("\n") response end def get_http_thread(url) Thread.new do log_then_get(URI(url), Thread.current) end end
1) get_http_thread takes a url (String) and converts it to a URI object
2) log_then_get defines its parameter as `url`, but really its expecting a URI object
3) get defines its parameter as `uri`, but we're passing it an argument called `url` from within log_then_get.
Lots of traps readily awaiting an unsuspecting programmer or newcomer to a project that contains code like this.
1) get_http_thread takes a url (String) and converts it to a URI object
2) log_then_get defines its parameter as `url`, but really its expecting a URI object
3) get defines its parameter as `uri`, but we're passing it an argument called `url` from within log_then_get.
Lots of traps readily awaiting an unsuspecting programmer or newcomer to a project that contains code like this.