One minute
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.
Code snippet ๐
# bad
something.instance_of?(Array)
# good
something.is_a?(Array)
something.kind_of?(Array)
Read other posts
comments powered by Disqus