Home > Back-end >  Swift: How I can partially apply generic function?
Swift: How I can partially apply generic function?

Time:10-21

i have some generic function, and i need to get a link to the generic function with a specific generic type.

// my generic function
func messageResult<M: SwiftProtobuf.Message>(_ dto: M?) {
    result(try? dto?.serializedData())
}

// then i try get link to the function with a specific generic type 
// but i throw error
let dtoResult = messageResult<Dto.OpenResult>

error message: '>' is not a postfix unary operator

ide highlighted: let dtoResult = messageResult<Dto.OpenResult

  • Related