KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to Ruby. A simple example, what I need: class Animal abstract eat() class Cat < Animal eat(): implementation class Dog < Animal eat(): implementation In other words, the eat() method should be required for all the classes which extend Animal. In JAVA I would just use an abstract class, but after doing some research I found that many people don't use it in Ruby and mixin / modules are recommended instead. However, I don't understand, if modules can do more than just include an addition methods. To be exact, can modules set the requirements for classes which methods they must implement (if yes, an example would be appreciated)? To sum up, what should I use in this case, when I want to be sure, that all classes of the same type have particular methods and implement them in their own way?
Tags (comma-separated)
Save Edits
Cancel