Always use is_a? or kind_of? over instance_of? πŸ™ŒπŸΌ

While all three methods looks similar, is_a? or kind_of? will consider the whole inheritance chain (superclasses and included modules), which is what you normally would want to do. instance_of?, on the other hand, only returns true if an object is an instance of that exact class you’re checking for, not a subclass.

Reference - Ruby Style Guide

Code snippet πŸ“Œ

# bad

# good