我收到錯誤“對泛型型別 'SomeResponse' 的參考需要 <...> 中的引數”
struct SomeResponse<T: Decodable>: Decodable {
let success: Bool
let body: T?
}
final class SomeService {
var response: SomeResponse? ///Reference to generic type 'SomeResponse' requires arguments in <...>
}
我不完全理解我應該寫入屬性“回應”的語法
uj5u.com熱心網友回復:
您的課程也應該是通用的。
final class SomeService<T: Decodable> {
var response: SomeResponse<T>?
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/439483.html
上一篇:如何從物件中提取MethodInfo.Invoke引數可能實作IEnumerable<T>
下一篇:如何呼叫具有通用引數的靜態方法,其約束為<T,TRepository>()whereTRepository:IRepository<T>,new()
