In Java, you can do instanceof. Is there a Ruby equivalent?
In Java, you can do instanceof. Is there a Ruby equivalent?
Adding another answer for completeness. Sometimes, particularly during testing, we may not want to access another class by type, so given a Hash:
h = { one: 'Val 1' }
instead of writing:
h.is_a? Hash # true
we can write:
h.class.name == 'Hash' # true