[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Constructor question

Han Holl

12/20/2004 3:26:00 PM


Hi,

I can't figure out why the following:

require 'curl'

a = Curl.new # constructor without arguments works !

class Geoserver < Curl
def initialize(plek)
super()
end
end

curl = Geoserver.new('plek')
# end-of-program

produces:

/tmp/curltest.rb:13:in `new': wrong number of arguments (1 for 0)
(ArgumentError)
from /tmp/curltest.rb:13

'curl' is the libcurl wrapper from RAA.

Cheers,

Han Holl


3 Answers

Yukihiro Matsumoto

12/20/2004 3:45:00 PM

0

Hi,

In message "Re: Constructor question"
on Tue, 21 Dec 2004 00:25:39 +0900, "Han Holl" <han.holl@informationslogik.nl> writes:

|I can't figure out why the following:

|curl = Geoserver.new('plek')

|produces:
|/tmp/curltest.rb:13:in `new': wrong number of arguments (1 for 0)
|(ArgumentError)
| from /tmp/curltest.rb:13
|
|'curl' is the libcurl wrapper from RAA.

Perhaps curl extension does not follow the object allocation
convention and redefines its own "new" method. You are not suppose to
subclass such a class. Ask curl developer.

matz.


ts

12/20/2004 3:47:00 PM

0

>>>>> "H" == Han Holl <han.holl@informationslogik.nl> writes:

H> /tmp/curltest.rb:13:in `new': wrong number of arguments (1 for 0)
H> (ArgumentError)

because 'curl' define the singleton method ::new which take 0 argument,
i.e. apparently it don't use the scheme allocate/initialize


Guy Decoux





Han Holl

12/20/2004 4:04:00 PM

0

On Monday 20 December 2004 16:45, Yukihiro Matsumoto wrote:
> Perhaps curl extension does not follow the object allocation
> convention and redefines its own "new" method. You are not suppose to
> subclass such a class. Ask curl developer.
>
> matz.

On Monday 20 December 2004 16:46, ts wrote:
> because 'curl' define the singleton method ::new which take 0 argument,
> i.e. apparently it don't use the scheme allocate/initialize
>
> Guy Decoux

Ah, I see.
Thanks to you both. I'll have to resort to some kind of delegation scheme
then.

Cheers,

Han Holl