“Interfaces & Abstract Classes unnecessary in Ruby” --> Can someone explain?

前端 未结 2 1834
小蘑菇
小蘑菇 2021-02-13 00:32

I\'m trying to wrap my head around Ruby, and one thing I\'m struggling with is the lack of interface/abstract class support. From googling about, the response I continuously see

2条回答
  •  天命终不由人
    2021-02-13 00:39

    there are ways to implement this type of thing, including abstract_type gem. While ruby doesn't require it and has mixins, i think there are cases, like adapters, where you'd want to secure your interface to a set of objects with something more explicit.

    also, check out http://metabates.com/2011/02/07/building-interfaces-and-abstract-classes-in-ruby/

提交回复
热议问题