Skip to content

Instantly share code, notes, and snippets.

@beccadax
Created June 13, 2014 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save beccadax/eba4c819eed3643bd489 to your computer and use it in GitHub Desktop.
Save beccadax/eba4c819eed3643bd489 to your computer and use it in GitHub Desktop.
In reply to @rnapier, here's how to reduce the implicit optionals in your code: factor them out.
func result() -> A {
var result : A = dispatch_sync(resultQueue, {
return self.result
})
return result
}
func dispatch_sync<R> (queue: dispatch_queue_t, block: Void -> R ) -> R {
var result: R!
dispatch_sync(queue) {
result = block()
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment