在swift中从泛型类派生的类的限制
发布时间:2020-12-14 06:02:48 所属栏目:百科 来源:网络整理
导读:我试图从通用类派生我的类: class fooT {}class bar : fooInt {} 但这个代码无法编译en错误: Classes derived from generic classes must also be generic 如何避免这个限制?可能吗? Ssreg, 不幸的是这是official: You can subclass a generic class,b
我试图从通用类派生我的类:
class foo<T> {} class bar : foo<Int> {} 但这个代码无法编译en错误:
如何避免这个限制?可能吗?
Ssreg,
不幸的是这是official:
让我们希望苹果在未来的版本中解决这个问题。 同时,让我们看到这是利用aggregation而不是子类化的机会。 注意: 作为一个穷人的版本的解决方案,可以使用typealias: class foo<T> {} class bar<Int> : foo<Int> {} typealias Bar = bar<Int> 这样,其余的代码可以写就像苹果已经解决了这个问题。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- react-native 轮播图 ——react-native-swiper使用
- ruby-on-rails – 控制Rails中使用的ruby版本
- Oracle : the Network Adapter could not establish the co
- postgresql – Alembic:alter column type
- ruby-on-rails – Rails 4强参数和嵌套形式
- ruby – ActiveJob :: SerializationError – 不支持的参数
- DWR以及SSH集成DWR
- ruby-on-rails – 在Activeadmin中删除回形针附件
- ReactOS 源码分析 (二) By:ProgrammeBoy
- quick-cocos2dx的windows版如何显示标题栏下方的菜单栏