Created
October 4, 2016 21:13
-
-
Save spf2/ed198c4e80a03cefbb23fe936338bf10 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
@objc protocol FooProtocol { | |
var bar: Set<String> { get set } | |
} | |
class Foo : FooProtocol { | |
var bar = Set<String>() | |
} | |
let a = Foo() | |
func toggle(foo: FooProtocol, item: String) { | |
if !foo.bar.contains(item) { | |
foo.bar.insert(item) | |
} else { | |
foo.bar.remove(item) | |
} | |
} | |
toggle(foo: a, item: "x") | |
print(a.bar) | |
toggle(foo: a, item: "x") | |
print(a.bar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment