+ 9
What is the difference between 'extend' and 'include' in ruby?
2 Answers
+ 2
" ... include is the most common way of importing external code into a class ...
Include
include is the most used and the simplest way of importing module code. When calling it in a class definition, Ruby will insert the module into the ancestors chain of the class, just after its superclass.Â
...
Extend
On the other end, using extend on a class will actually import the module methods as class methods.
... "
Source : ( code examples included showing implementation ) https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073
+ 2
Extending is using a preexisting class or methods library and tapping into its resources to perform futher functionality. Include is importing a library or class type INTO the programming. Its same with Java and C++ except they use #include in C++ when its import in Java. The terminology may be slightly diff but concept and actions performed are same.