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

Ruby Ruby Foundations Testing MiniTest

What is the difference of "extend" and the "<" sign?

Hello, I just want to know the differences, in the videos Jason never elaborate about the "<" when namming a class. What I understood is that it brings the methods that has the module in front of the "<" simbol? but I though that was made by the "extend" keywork

So now I feel confused with this new concept. Thanks for the help

1 Answer

Hi Sebastian,

In Ruby, when you create a class and put the < sign after it, it means the class inherits from another one. For example.

class Pet

attr_accessor :name, :age, :gender, :color

class Dog < Pet

The < sign means the Dog class inherits the attributes of the Pet class.

Extend relates to modules. Check out http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/ for a good discussion of the use of extend in modules.

Hope this helps to clarify things.

Happy coding,

Ronald

Thanks for your explanation =) now it's clear to me it's inheritance lol thanks!