Ruby Interview Questions : Include vs Extend
What is the difference between include and extend? How to implement extend with include? Watch the video here: Include and Extend
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
What is the difference between include and extend? How to implement extend with include? Watch the video here: Include and Extend
Comments
This does not really explain the difference between include and extend. My understanding is that include differs from extend in that it can it instance methods to a class. A common ruby idiom is to also add class methods via the included hook plus extend.
I’m not sure why you would want to use include to add class methods (without going through the included hook) versus extend as shown above in the video.
Here’s a much better explanation in my opinion: http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
I have made the correction. The video does not address the question: What is the difference between include and extend?
Post a comment