Scala 中的有界泛型(如 Java 中的)
我正在将一个应用程序从 java 迁移到 Scala。 在java中我有类似的东西
abstract class CommonObjectInfo{//...}
class ConcreteObject extends CommonObjectInfo{//...}
abstract class AbstractWrapper<E extends CommonObjectInfo>{//...}
class ConcreteWrapper extends CommonObjectInfo<ConcreteObject>{//...}
How can I Form Iexpress the "wrappers" object in Scala?我
I'm migrating an app from java to Scala.
In java I have somethng like
abstract class CommonObjectInfo{//...}
class ConcreteObject extends CommonObjectInfo{//...}
abstract class AbstractWrapper<E extends CommonObjectInfo>{//...}
class ConcreteWrapper extends CommonObjectInfo<ConcreteObject>{//...}
How can I express formally the "wrappers" objects in Scala? I
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常的解决方案是来自agilesteel的解决方案,但有时将类型信息拉入类“内部”很有用(特别是当所讨论的类型被认为是实现细节时):
The usual solution is the one from agilesteel, but sometimes it's useful to pull the type information "inside" the class (especially when the type in question is considered to be an implementation detail):