又是歡樂的一集!今天聊起 #weakself挑戰賽)的 Type Erasure 與 Opaque Return Type。不過,怎麼某人的聲音到後半段就 erased 了!? { 完整節目筆記 https://weakself.dev/episodes/13) }
上一集成為最熱門集數,所以跟新朋友打招呼、解釋一下我們的名稱
weak self 這個名稱,寫 Swift 或 iOS 工程師一看就知道。但我們其實沒有中文名稱,大家可以幫忙想
weak self, strong community
鐵人賽 iOS Developer Learning Android 系列) by @MarkFlyyyyy )30 天了解 Swift 的 Combine )最高觀看數 bug? )其他整理請見«13的開發者週報» )
PAT 是什麼?看 code) PAT 三不能:
不能做為變數型別用
不能做為 function 的 return
不能放在 Collection 裡
你是忘記還是害怕想起:
PAT 難搞的地方有兩種:
有 Self
的 Protocol:Hashable
有 associatedtype
的 Protocol:IteratorProtocol
對應的做法:
weakself 的中文名稱是個 Opaque Type (Caller 決定 generic 是什麼)
Opaque Return Type 則由 Callee 決定 generic 是什麼
避免 generiception:
`public typealias LazyCompactMapCollection<Elements, ElementOfResult>
-> <C: Collection> C where C.Element == ElementOfResult
= LazyMapSequence<LazyFilterSequence<LazyMapSequence<Elements, ElementOfResult?>>, ElementOfResult>`
也是對於 Type Erasure 的一種根本性解決手法
範例請見:https://gist.github.com/pofat/a411d785e593982868a54e140f48ad8f)
抱歉,還無法🤷♂️
Twitter @weak_self)
提問箱)
-- Hosting provided by SoundOn)