Better HN
topnewbestaskshowjobs
Log inSign up

blarney_stone

1 karma · joined Jun 19, 2014 (12y ago) · 1 submissions

Submissions

comment 12y ago · link · parent

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.