typealias of generic class in Swift

前端 未结 3 1839
孤城傲影
孤城傲影 2021-02-19 04:29

I am trying to make a typealias of a generic type class as follows

class Cars {
  ...
}

typealias SportCars = Cars

but I am getting a

3条回答
  •  野性不改
    2021-02-19 05:20

    Possible workaround is to wrap type alias into class/struct:

    struct SportCars {
      typealias T = Cars
    }
    
    /// Usage:
    typealias Foo = SportCars.T
    

提交回复
热议问题