브라우징 스위프트의 라이브러리 코드는 내가 발견했습니다스위프트에서 모든 유형을 확장 하시겠습니까?
이extension T! : Printable {
var description: String { get }
}
코드 조각은 '설명'필드의 모든 유형을 확장 할 것으로 보인다. 내 코드에서 같은 일을하려고 할 때 , 내가 얻을 오류 :
- How can I extend typed Arrays in Swift?
- What's the difference between Optional<T> and optional types in Swift? Extending Optional to carry error information? :
example.swift:10:11: Non-nominal type 'T!' cannot be extended
protocol MyProtocol { // ... } extension T! : MyProtocol { // error: Non-nominal... // ... }
에서 유사한 질문이 있습니다
그러나 그들은 해결하기 위해 실패합니다
- 여기 무슨 일이야? 왜 도서관 코드는 괜찮지 만 내 코드는 ... 아닌가?
- 특정 프로토콜을 준수하는 모든 유형 또는 모든 유형이 가능합니까?
비슷한 질문 (대답이 없습니다) : http://stackoverflow.com/questions/24185549/whats-the-difference-between-optionalt-and-optional-types-in-swift-error-ha. –
스위프트 개발자가 일부 기능을 자체적으로 유지하면서 [여기에 몇 가지 표준이 적용됩니다] (http://en.wikipedia.org/wiki/Quod_licet_Iovi,_non_licet_bovi)가있을 수 있습니다. – dasblinkenlight
네 말이 맞아!라이브러리 코드가 작동하지만 내 코드가 컴파일되지 않는 이유를 알고 싶습니다. – Andy