Randy Steele
Posted on February 22, 2021
I once was asked in an interview what the difference between a class and an object is and of course, I froze! So, I wanted to talk about it a little bit.
A class describes the contents of the objects that belong to it. I can define a class like this
class Blog
end
Once a class is created you can create a new object that will belong to the Blog class.
Objects can be strings, integers, symbols etc. Every object has a class and classes define objects. I can create an object like this
myblog = Blog.new
So basically the class is like the blueprint. I can have a blog class and it will have properties or attributes such as content and title, and if I created an object from the Blog class called myblog then that object would have a content title and attributes.
I hope this helps!
Posted on February 22, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.