Generics in Scala: implementing an interface/trait twice?

前端 未结 2 2026
無奈伤痛
無奈伤痛 2021-02-19 21:09

Given a generic interface such as the following

interface I {
    void m(T t);
}

I can in C# create a class that implements I twice (o

2条回答
  •  感情败类
    2021-02-19 21:34

    No, it can't. Generally what I do in this case is

    class C {
      object IInt extends I[Int] { ... }
      object IString extends I[String] { ... }
      ...
    }
    

提交回复
热议问题