Re: [GD-General] RE: Ruby
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2001-12-28 04:58:10
|
At 08:00 PM 12/27/2001 -0800, Jesse Jones wrote: >BTW one of the really cool things about Ruby is that classes aren't closed. Same with Obj-C. You can extend an existing class, sans source code, by creating a "category". @interface ClassToExtend (NewMethods) - ( int ) newMethod; @end You then implement them in a separate implementation area (just like regular Obj-C classes), and from that point on you can call those new methods directly on the object: ClassToExtend *c = [[ClassToExend alloc] init]; int i = [c newMethod]; //Call "newMethod" on a class that I didn't write You can only change the interface, not the implementation, since changing the latter would cause a change in the class' size. There can be some problems with name collisions if you're not careful. Brian |