Use is_a? when checking class
Do not use ==
when checking that an object is of a given class.
Whilst it works here:
> Array.new.class == Array
=> true
…it won’t work with descendants of the class we’re checking against:
> class Thing < Array; end
=> nil
> Thing.new.class
=> Thing
> Thing.new.class == Array
=> false
Instead use is_a?
:
> Array.new.is_a? Array
=> true
> Thing.new.is_a? Thing
=> true
> Thing.new.is_a? Array
=> true