From: Brian Candler Date: 2010-09-15T06:46:22+09:00 Subject: Re: HTTP POST Noel Mc grath wrote: > If > you look at the HTTP response it has the following two objects - resp, > responsedata. This one had me stumped for a while. Actually, it returns only one object. But that object has a to_ary method, which is called in the case of multiple assignment. So: res1 = http.post(...) just gets the response object. But res1, res2 = http.post(...) is doing an implicit splat, which calls to_ary, which turns it into [self, self.body], and those two values get assigned to res1 and res2. This is extremely sneaky, and the code issues a warning if you run ruby with the -w flag (which you should always do) # For backward compatibility. # To allow Net::HTTP 1.1 style assignment # e.g. # response, body = Net::HTTP.get(....) # def to_ary warn "net/http.rb: warning: Net::HTTP v1.1 style assignment found at #{caller(1)[0]}; use `response = http.get(...)' instead." if $VERBOSE res = self.dup class << res undef to_ary end [res, res.body] end -- Posted via http://www.ruby-forum.com/.