I’m having two problems extending the array class.
First, I am getting instances where super == nil. It seems to me that
this should be impossible. The code that results in super == nil is as
follows:
def TypedArray.initWithArray(parent, content)
ta = TypedArray.new(parent)
content.each() { |val| ta << val }
return ta
end
When I take this returned object and run methods that access super,
super will equal nil. For example:
def [](colNum)
puts ("******************super == nil") if super == nil;
return super[@parent.colsIdx[colNum]]
end
The above method will print the “super == nil” string and throw the
exception saying [] is not defined for nil.
Second, I am redefining the [] and []= methods, so within those, I have
to access super[]= and super[] (or else I’ll have an infinite regress).
For example:
def []=(colNum, val)
super[@parent.colsIdx[colNum]] = val
end
I am getting very odd results. For example, a[0] = “yet another test
col 0” actually sets a[0] to “yet anothyet another test col 0r test col
0”. Moreover, if I insert the following line:
puts(super.type)
I get “String” every time.
These results strike me as anomalous and are too bizarre for me to
explain, especially give the fact that my source code is rather
rudimentary.
I am using ruby 1.6.7 on MacOS X 10.2.3. I am using the version that
came with the developer tools, and ruby --version gives me the
following:
ruby 1.6.7 (2002-03-01) [powerpc-darwin6.0]
Thanks,
Dave
PGP.sig (186 Bytes)