Skip to content

Instantly share code, notes, and snippets.

@kongtomorrow
Created August 18, 2014 19:34
Show Gist options
  • Save kongtomorrow/d36550fe7da2e84c8559 to your computer and use it in GitHub Desktop.
Save kongtomorrow/d36550fe7da2e84c8559 to your computer and use it in GitHub Desktop.
Swift seed 6: lexical scope nope?
func foo() {
func bar(x:Int)->String {
return "hello"
}
[1,2,3].map({bar($0)}) // "Cannot reference a local function from another local function"
}
@ColinEberhardt
Copy link

Interestingly the following change makes it work:

let bar :(Int)->(String) = { (Int)->String in
    return "hello";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment