Skip to content

Instantly share code, notes, and snippets.

@swhitty
Created December 14, 2016 09:29
Show Gist options
  • Save swhitty/caf49fe341a0264fbb990c28a2f07682 to your computer and use it in GitHub Desktop.
Save swhitty/caf49fe341a0264fbb990c28a2f07682 to your computer and use it in GitHub Desktop.
struct AnyEquatable: Equatable {
let base: Any
let isEqual: (_ other: AnyEquatable) -> Bool
init<T: Equatable>(_ base: T) {
self.base = base
self.isEqual = { base == $0.base as? T }
}
public static func ==(lhs: AnyEquatable, rhs: AnyEquatable) -> Bool {
return lhs.isEqual(rhs)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment