【发布时间】:2014-09-03 14:50:42
【问题描述】:
在 iOS 上运行的编程语言中的泛型?不必多说了,把我的钱拿去!
这是我的实验代码(在操场上运行):
class Foo<GenericType1> {
var value:GenericType1?
init(value:GenericType1) {
self.value = value;
}
}
class Foo2<GenericType2> : Foo<GenericType2> {
override init(value:GenericType2) {
super.init(value:value);
}
}
extension Foo {
class func floop<T>(value: T) -> Foo2<T> {
return Foo2<T>(value:value)
}
}
接着是:
var foo = Foo.floop("test")
最后一部分抛出错误信息:
Cannot convert the expression's type 'StaticString' to type 'StringLiteralConvertible'
我一辈子都想不通为什么。任何帮助将不胜感激。
【问题讨论】:
标签: ios xcode generics swift swift-playground