Answer the question
In order to leave comments, you need to log in
Why is there no abstract class in Ruby?
Maybe someone knows? And is it really a good way to emulate an abstract class?
class AbstractEmulate
def requiredMethod
#abort() or throw Exception here
end
def requiredMethodTwo
abort("Please define #{__method__.to_s}")
end
end
Answer the question
In order to leave comments, you need to log in
stackoverflow.com/questions/715604/why-do-dynamic-...
Ruby/python doesn't really need abstract classes. In any case, the authors of languages thought so, based on the idea that in these languages all checks for the existence of methods occur at runtime, well, you can replace methods at runtime and do a lot more with classes.
Maybe someone knows? And is it really a good way to emulate an abstract class?
Ruby is a language that is pure OOP, so all objects that exist in it are already de facto abstract. in each object in Ruby (and in Ruby EVERYTHING is an object) you can add at runtime, change behavior, destroy a method, override, supplement, and whatever you like, Ruby, like Smalltalk, is a pure OO language and therefore the whole world is for them both an object and abstraction at the same time each object can be augmented, there may be empty objects that are filled in later (same work of abstraction in C# "abstract class")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question