Hacker News new | past | comments | ask | show | jobs | submit login

> Are you coming from java?

Well, java was one of the languages I used before Ruby, but I've done more Ruby than Java.

> Read up on http://en.wikipedia.org/wiki/Duck_typing

I am well aware of duck typing, and rarely use either #is_a? or #respond_to?

That doesn't change that, if you have a reason to use that type of inquiry to check interfaces, #is_a? is the more safe of the two (more likely to reject an object that provides the semantics of concern and less likely to accept one that does not) and #respond_to? is the less safe (more likely to accept an object that does not provide the semantics of concern and less likely to reject one that does.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: