Hello!
Yep I'm having a problem similar to that previously posted about here but the circumstances aren't quite the same and the suggested solutions don't work anyway. The situation...
I am subclassing Dictionary because i want to code to an "interface" rather than the Dictionary class as I want the flexibility of changing the parent class to some other collection if that seems appropriate. So, I did something like this:
Dictionary subclass: #MySubclass...
All other details of the subclass definition are left to "asis" in the subclass template. However, when is send Myclass>>at:put: the method fails with error message "only integers should be used as indices".
The proposed solutions to other similar issues reported by others were:
- overide MyClass class>>new as follows: ^super new initialize (actually, override the parent's new) - add <shape: #inherit> to the body of the class
I tried the former expecting no change (why should it work?) and my expectation was realized. The latter doesn't specify where in the class body to add <shape: #inherit> but tried each of the following individually:
- Revised: Dictionary subclass: #MySubclass shape: #inherit... - Added MySubclass>>shape ^#inherit -Added MySubclass class>>shape ^#inherit.
Doubtless someone out there knows what I should have done, but what I did do failed in each case with the same error message.
So, I'm stumped at this point. I know that adding "index: #object" to the subclass definition works in another implementation of Smalltalk, but Squeak doesn't seem to recognize index:. Still stumped.
One last thing I found while hunting and pecking for a clue that I don't understand. Squeak documentation states that Dictionary is a subclass of Set, and in other implementations of ST that is indeed the case (I believe the ST standard specifies the same). However, the system browser shows that Dictionary is a subclass of HashedCollection...???
Enough verbiage. Any suggestions/fixes folks? All responses will be greatly appreciated.
Andres
-- View this message in context: http://forum.world.st/Subclassing-Dictionary-Redux-tp4900765.html Sent from the Squeak - Beginners mailing list archive at Nabble.com.