[swift-users] Function conforming to a typealias

Adrian Zubarev adrian.zubarev at devandartist.com
Sat Feb 18 04:52:44 CST 2017

Not sure what you’re trying to solve there but you could use it like this with closures:

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

let myGreatFunc1: Function = { _ in return nil /* or whatever you need there */ }
let myGreatFunc2: Function = { _ in return nil }

Adrian Zubarev
Sent with Airmail

Am 18. Februar 2017 um 11:47:26, Rien via swift-users (swift-users at swift.org) schrieb:

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?


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

func myGreatFunc1:Mysig {…}

func myGreatFunc2:Mysig { …}


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


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

swift-users mailing list
swift-users at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170218/99df6013/attachment.html>

More information about the swift-users mailing list