Last active
August 29, 2015 14:27
-
-
Save hartbit/cb1e986728579d04435f to your computer and use it in GitHub Desktop.
Using self in closure to super.init
This file contains hidden or 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
| class A<T> { | |
| init(closure: (T -> Void) -> Void) {} | |
| } | |
| class B<T> : A<T> { | |
| private var lastValue: T? | |
| override init(closure: (T -> Void) -> Void) { | |
| super.init(closure: { sink in | |
| closure { value in | |
| self.lastValue = value | |
| sink(value) | |
| } | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment