Skip to content

Instantly share code, notes, and snippets.

@bencochran
Last active August 29, 2015 14:06
Show Gist options
  • Save bencochran/8e87240f540f33fbe0ba to your computer and use it in GitHub Desktop.
Save bencochran/8e87240f540f33fbe0ba to your computer and use it in GitHub Desktop.
Swift specificity
import Foundation
func doStuff(item: Any) {
println("Do stuff with this: \(item)")
}
class Foo {
func doStuff() {
doStuff(self) // <- Won’t compile. “Cannot convert 'Foo' to type '() -> ()'”
}
}
let f = Foo()
doStuff(f)
f.doStuff()
@bencochran
Copy link
Author

In a non-playground setting, looks like you can specify ModuleName.doStuff() to get at the right function.

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