【发布时间】:2020-09-17 21:29:31
【问题描述】:
我有课
class MyClass<T> { /***/ }
我想扩展的:
extension MyClass where T: Codable & RawRepresentable & CaseIterable { /***/ }
我想将扩展限制为 String 类型的 RawValues,因此我尝试执行以下操作:
extension MyClass where T: Codable & RawRepresentable & CaseIterable, RawValue == String {
func doSomething() {
print("doing something with strings!")
}
}
当然这不起作用,但是有没有办法让它起作用?
尽可能明确会有所帮助
【问题讨论】:
标签: ios swift generics associated-types