Created
April 22, 2019 14:55
-
-
Save jpmcglone/1734135ca22913076af77c6a87b6cc22 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
import Foundation | |
class Weak<T> { | |
private weak var _value: AnyObject? | |
var value: T? { return _value as? T } | |
init(_ value: T) { | |
_value = value as AnyObject | |
} | |
} | |
extension Array { | |
mutating func cleanup<T>() where Element == Weak<T> { | |
self = self.filter { $0.value != nil } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment