跳到主要內容

發表文章

目前顯示的是 5月, 2017的文章

Function Type

https://www.youtube.com/watch?v=Cb0sy_H0LfU https://code.tutsplus.com/tutorials/swift-from-scratch-function-parameters-types-and-nesting--cms-23056 6.  Function Types Functions as Parameters In the  previous article , we briefly touched upon function types. A function has a particular type, composed of the function's parameter types and its return type. The  printMessage(_:)  function, for example, is of type  (String) -> () . Remember that  ()  symbolizes  Void , which is equivalent to an empty tuple. Because every function has a type, it's possible to define a function that accepts another function as a parameter. The following example shows how this works. 01 02 03 04 05 06 07 08 09 10 11 func printMessage(_ message: String) {      print(message) } func printMessage(_ message: String, with function : (String) -> ()) {      function (message) } ...