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

前端 未结 2 435
时光说笑
时光说笑 2021-02-13 00:36

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 01:02

    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/

提交回复
热议问题