Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Created March 10, 2015 19:32
Show Gist options
  • Save bjhomer/de7e630b0ce4d1f4d3b6 to your computer and use it in GitHub Desktop.
Save bjhomer/de7e630b0ce4d1f4d3b6 to your computer and use it in GitHub Desktop.
protocol FooProtocol {
func blah()
}
struct Foo : FooProtocol {
func blah() {}
}
struct FooTaker {
init(inout aFoo: FooProtocol) {
println("I got a foo! \(aFoo)")
}
}
let x: FooProtocol? = Foo()
if var foo = x {
FooTaker(aFoo: &foo)
}
@hborders
Copy link

https://gist.github.com/bjhomer/de7e630b0ce4d1f4d3b6#file-gistfile1-txt-L18

What are the guarantees around foo's lifetime? Won't it go away with the stack?

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