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
something.instance_of?(Array)

# good
something.is_a?(Array)
something.kind_of?(Array)