Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
David Forero
5,492 PointsHow could you help me understand what a class means? I am confused between methods and classes?
How could you help me understand what a class means? I am confused between methods and classes? Are they both containers for data? I am looking to get these concepts clear. Thanks before hand.
2 Answers
Maciej Czuchnowski
36,441 PointsThink of it this way:
You, David, belong to a class named "human". There is a general class that defines common things that all humans share. So class is a general concept from which particular objects are created: David, John, Maciej etc. They all have some attributes (variables), but these variables will differ: the variable name will be different for each human. height for someone will equal to 190cm, for someone else it will be 155cm. The weight variable for someone will be 50kg, for someone else - 100kg. All humans (objects belonging to class "human") will also have some methods - things they can all do, for example .sleep, .eat etc. So to sum up: class is an abstract representation of objects that have some stuff in common, and methods are things that these objects can perform, either defined by you or by default Ruby library.
David Forero
5,492 PointsThank you very much Maciej ! This clarifies everything.
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsGreat response.