In statically typed languages, runtime polymorphism is more difficult to achieve. Fortunately, withwe can use duck typing .
We'll use ourand parsers again for this example, minus the inheritance: class XmlParser def parse puts 'An instance of the XmlParser class received the parse message' end end
class JsonParser def parse puts 'An instance of the JsonParser class received the parse message' end end
Issue 1-14: Duck Typing in (1 of 2)
Issue 1-16: Interesting Hackers
Issue 1-19: Thoughts on (1 of 2)
There are still 7 more to be publicly released from volume 1, but I've already begun work on volume 2.of the Ruby Mendicant supporter network …
I'm being sarcastic here, of course I don't think that Duck Typing can substitute LSP. Have a look at behavioral conditions section in the wikipedia article for reasons. The fact that LSP is attracting attention right now can be pretty telling. I'm excited to witness it. Community is finally seeking for some grownup approaches, great! However, the question is: doesn't that get us closer to some limitations of our beloved highly dynamic language?
Rails code is rapidly …