OOP - 如何在Reason中创建构造函数

时间:2017-10-11 03:00:17

标签: oop ocaml reason

假设我有两个具体的工厂:

class concreteFactory1 = {
  inherit abstractFactory;
  pub createProductA => (new productA1);
  pub createProductB => (new productB1);
};

class concreteFactory2 = {
  inherit abstractFactory;
  pub createProductA => (new productA2);
  pub createProductB => (new productB2);
};

然后我希望有另一个类调用工厂方法(例如concreteFactory1#createProductA),基于工厂传入类。类似于以下内容(语法错误,我知道):

class testFactory factory => {
  as _;
  pub createProductA => Js.log factory#createProductA;
};

任何建议都非常受欢迎。谢谢。

0 个答案:

没有答案