When to use typealias?

前端 未结 2 1269
夕颜
夕颜 2021-02-14 17:17

So far I understand that the typealias is a named alias of an existing type. By using typealias, I could do something like:

typealias MyString = String
var str:          


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 17:37

    The common way to use typealias for me is working with closures:

    typealias VoidClosure = () -> Void

    func updateFrom(completion: @escaping VoidClosure) { }

提交回复
热议问题