How to get ruby class of an object?

In Ruby programming method ‘class’ is used to get ruby class of an object. Method ‘class’ is used to tells an object to display its class, See an example below:

Suppose class name is ‘AnimalName’ And object name is ‘cat’

class AnimalName

end

cat = AnimalName.new

 

puts cat.class

#=> displays: “AnimalName”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.