[swift-users] Function conforming to a typealias

Rien Rien at Balancingrock.nl
Sat Feb 18 04:46:08 CST 2017


I want to create a few functions that all have the same signature.

The signature is defined in a typealias

Is there any way to shortcut the function definition, or alternatively ensure that the function signature will always be equal to the typealias?

Examplecode:

typealias Mysig = (Int, Bool) -> String?

func myGreatFunc1:Mysig {…}

func myGreatFunc2:Mysig { …}

Alternatively

@conformsTo(Mysig)
func myGreatFunc1(_ a:Int, _ b: Bool) -> String? {…}

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl







More information about the swift-users mailing list