Last active
October 13, 2016 01:46
-
-
Save abiodun0/5b377362d9c37a37f978ae857c2aa245 to your computer and use it in GitHub Desktop.
type Alias function with closure callback in swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias function = (String) -> String | |
let someProperty: function = {(value: String) -> String in | |
// create a default value for someProperty inside this closure | |
// someValue must be of the same type as SomeType | |
return value | |
} | |
print(someProperty("abiodun")) | |
// This can be refactored to this | |
typealias function = (String) -> String | |
let someProperty: function = {(value: String) in | |
value | |
} | |
print(someProperty("abiodun")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment