Something I've always known Ruby could do, but never knew there was a word for: duck-typing. In short, duck-typing is object-oriented hierarchy without explicitly defining two things as being of the same family. Basically, where Java would throw a compile error if you were to use a "Person" class when you asked for a "Duck" class, Ruby would compile just fine, and even run it if the "Person" class has a "Quack" method that you call.
I didn't really use it too much in the assignment, but I do like the naming for it. It's very evocative of it's function and a decent little joke. Programmers tend to have a strange sense of humor.
No comments:
Post a Comment