I think I would object to linking polymorphism to inheritance (which you kind of implied but didn't exactly do, so maybe you didn't mean that). Obj-C polymorphism is about the ability to send a message to an object without any particular requirement on the type of the object. The standard Print menu item, for example, relies on the polymorphism of the print: IBAction selector to enable printing for the circle, the star, the rectangle and the Word document. In fact, in Obj-C, polymorphism boils down to run-time dispatch. Swift tends to de-emphasize actual polymorphism by focusing on slightly polymorphic-ish features such as protocols and inheritance, which have significant compile-time limits when compared with Obj-C's free-for-all.However, what I really want to say is that in Swift, protocols and inheritance are not just alternative tools. There's a whole series of difficulties in using inheritance (fragile base classes, multiple inheritance, etc) that have led to
Topic:
Programming Languages
SubTopic:
Swift
Tags: