Skip to content

Instantly share code, notes, and snippets.

@Leechael
Created June 3, 2014 07:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leechael/76675b60fa4f479a49dc to your computer and use it in GitHub Desktop.
Save Leechael/76675b60fa4f479a49dc to your computer and use it in GitHub Desktop.
Property as method and overriding in Swift (impossible for method)
import Cocoa
class A {
var foo : () -> String
var baz : Int
init () {
func _foo () -> String {
return "halo"
}
self.foo = _foo;
self.baz = 1
}
func jaz () -> String {
return "jazz"
}
}
func _bar () -> String {
return "benjour"
}
var b = A()
b.foo()
//b.jaz = _bar // Cannot assign to 'jaz' in 'b'
b.foo = _bar
b.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment