HNHacker News
TopNewBestAskShowJobs

blarney_stone

1 karma · joined June 19, 2014

submissionscomments
blarney_stone··on Function hooking in Swift
I've seen this concern that there are no function pointers in swift, and it seems to come from a misunderstanding on what it means for functions to be first class.

From https://developer.apple.com/library/prerelease/ios/documenta... :

You use function types just like any other types in Swift. For example, you can define a constant or variable to be of a function type and assign an appropriate function to that variable:

var mathFunction: (Int, Int) -> Int = addTwoInts

mathFunction can now be passed around, fed in as a parameter in another function, etc. mathFunction is for all purposes a function pointer.