Last active
September 3, 2015 07:01
-
-
Save Kametrixom/8e9887defd210a737e72 to your computer and use it in GitHub Desktop.
This file contains 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
// This one is quite tricky | |
let returnN = getReturnN() | |
func availableToIntCollection<C: CollectionType where C.Generator.Element == Int>(c: C) {} | |
availableToIntCollection([1, 2, 3].lazy.map(returnN)) | |
var a : Int { returnN (n: 3) } | |
var b : Int { return N(n: 3) } |
It strikes me as strange that we can annotate a closure with @NoReturn when defining its type, but can't define such a closure directly; it must have a named function assigned to it instead. At least we can define nested functions:
func getReturnN() -> @noreturn (n: Int) -> Int {
// Two n's are not needed; in fact, not even one is!
// Only the parameter name in the return value matters.
@noreturn func returnN(_: Int) -> Int {}
return returnN
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@noreturn
Ahhh I was missing this one, nice!!!