Re: not sure what is wrong. strange error
- From: Hugh Sasse <hgs@xxxxxxxxx>
- Date: Sat, 16 Sep 2006 02:47:32 +0900
On Sat, 16 Sep 2006, Junkone wrote:
My class declation is like this
class TorontoTraderLoader
INDEX_SYMBOL=2
STOCK_SYMBOL=1
@backTestDb=['backtestBackTest', 'user','pass']
def initialize(backTesting)
@exchanges=@industries=@sectors=@stocksymbols=''
@dbcon=DbAccess.new(@backTestDb)
loadLookup
end
def initialize()
@exchanges=@industries=@sectors=@stocksymbols=''
loaddbConn
loadLookup
end
...
I get the following error and it is so odd
irb(main):001:0> require 'TorontoTraderLoader'
=> true
irb(main):002:0> a=TorontoTraderLoader.new('ww')
ArgumentError: wrong number of arguments (1 for 0)
from (irb):2:in `initialize'
from (irb):2
It does not make any sense. i have a overloaded constructor. i am not
No, you redefined it. No overloading in Ruby (because "Duck Typing")
sure why it does not call teh overloaded constructor
Maybe
def initialize(backTesting = nil)
@exchanges=@industries=@sectors=@stocksymbols=''
if backTesting.nil?
@dbcon=DbAccess.new(@backTestDb)
else
loaddbConn
end
loadLookup
end
is more the kind of think you want, but in the first method you
don't seem to use the param backTesting anyway.
Hugh
.
- References:
- not sure what is wrong. strange error
- From: Junkone
- not sure what is wrong. strange error
- Prev by Date: Re: readline() with editing and history?
- Next by Date: Re: Benchmark for Ruby
- Previous by thread: Re: not sure what is wrong. strange error
- Next by thread: irb freaks out over a case stmt...
- Index(es):