Skip to content

Instantly share code, notes, and snippets.

@abiodun0
Last active October 13, 2016 01:46
Show Gist options
  • Save abiodun0/5b377362d9c37a37f978ae857c2aa245 to your computer and use it in GitHub Desktop.
Save abiodun0/5b377362d9c37a37f978ae857c2aa245 to your computer and use it in GitHub Desktop.
type Alias function with closure callback in swift
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