[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Old style assignment

Michael Thomas

11/10/2003 3:35:00 PM

I got the following warning. Can anyone tell me what the new style is?
TIA!!!

resp, data = h.get('/index.html', nil )
net/http: warning: old style assignment found at ./test.rb:6

MT

5 Answers

Marek Janukowicz

11/10/2003 3:45:00 PM

0

On Mon, 10 Nov 2003 08:34:31 -0700, Michael Thomas wrote:
> I got the following warning. Can anyone tell me what the new style is?
> TIA!!!
>
> resp, data = h.get('/index.html', nil )
> net/http: warning: old style assignment found at ./test.rb:6

resp = h.get('/index.html', nil )
data = resp.data

--
Marek Janukowicz

ts

11/10/2003 3:49:00 PM

0

>>>>> "M" == Michael Thomas <mthomas1234@hotmail.com> writes:

You have the documentation in the source of http.rb

M> resp, data = h.get('/index.html', nil )
M> net/http: warning: old style assignment found at ./test.rb:6

# Gets data from +path+ on the connected-to host.
# +header+ must be a Hash like { 'Accept' => '*/*', ... }.
#
# In version 1.1 (ruby 1.6), this method returns a pair of objects,
# a Net::HTTPResponse object and the entity body string.
# In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse
# object.
#
# If called with a block, yields each fragment of the
# entity body in turn as a string as it is read from
# the socket. Note that in this case, the returned response
# object will *not* contain a (meaningful) body.
#
# +dest+ argument is obsolete.
# It still works but you must not use it.
#
# In version 1.1, this method might raise an exception for
# 3xx (redirect). In this case you can get a HTTPResponse object
# by "anException.response".
#
# In version 1.2, this method never raises exception.
#
# # version 1.1 (bundled with Ruby 1.6)
# response, body = http.get('/index.html')
#
# # version 1.2 (bundled with Ruby 1.8 or later)
# response = http.get('/index.html')
#
# # using block
# File.open('result.txt', 'w') {|f|
# http.get('/~foo/') do |str|
# f.write str
# end
# }
#

1.1 is the old style

--

Guy Decoux

Simon Strandgaard

11/10/2003 3:52:00 PM

0

On Mon, 10 Nov 2003 08:34:31 -0700, Michael Thomas wrote:

> I got the following warning. Can anyone tell me what the new style is?
> TIA!!!
>
> resp, data = h.get('/index.html', nil )
> net/http: warning: old style assignment found at ./test.rb:6

I cannot provoke the same warning, which version of Ruby do you have?

server> ruby -v b.rb
ruby 1.8.1 (2003-10-31) [i386-freebsd5.1]
server> cat b.rb
h = [1, 2]
def h.get(a, b); self end
n, m = h.get('/index.html', nil )
server>

--
Simon Strandgaard

Michael Thomas

11/10/2003 3:57:00 PM

0

Simon Strandgaard wrote:
> On Mon, 10 Nov 2003 08:34:31 -0700, Michael Thomas wrote:
>
>
>>I got the following warning. Can anyone tell me what the new style is?
>> TIA!!!
>>
>>resp, data = h.get('/index.html', nil )
>>net/http: warning: old style assignment found at ./test.rb:6
>
>
> I cannot provoke the same warning, which version of Ruby do you have?
>
> server> ruby -v b.rb
> ruby 1.8.1 (2003-10-31) [i386-freebsd5.1]
> server> cat b.rb
> h = [1, 2]
> def h.get(a, b); self end
> n, m = h.get('/index.html', nil )
> server>
>
> --
> Simon Strandgaard

I should have told you it's 1.8.0 and listed the code:

require 'net/http'
h = Net::HTTP.new('www.cnn.com', 80)
resp, data = h.get('/index.html', nil )

any idea?

daz

11/19/2003 4:54:00 AM

0



> > I got the following warning. Can anyone tell me what the new style is?
> > TIA!!!
> >
> > resp, data = h.get('/index.html', nil )
> > net/http: warning: old style assignment found at ./test.rb:6
>
> resp = h.get('/index.html', nil )
> data = resp.data
^^^^
>

data = resp.body
^^^^



(Maybe a repeat typo' from the reply to: http://www.ruby-talk...)


daz