-
-
Save LTe/51075e63b7aa840c3361 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
class EventFeed: Hashable, Equatable { | |
var eventId = 0 | |
var hashValue : Int { return eventId } | |
func equals(another: EventFeed) -> Bool { | |
return self.eventId === another.eventId | |
} | |
} | |
func ==(lhs: EventFeed, rhs: EventFeed) -> Bool { | |
return lsh.equals(rhs) | |
} | |
class PostUpload : EventFeed { | |
var postId : Int | |
override var hashValue : Int { return postId } | |
init(id: Int) { | |
postId = id | |
} | |
func equals(another: EventFeed) -> Bool { | |
return self.postId === another.posttId | |
} | |
} | |
var postQueue = [PostUpload]() | |
let importantPost = PostUpload(id: 12) | |
postQueue.append(PostUpload(id: 10)) | |
postQueue.append(importantPost) | |
//this should be 1, not 0 | |
let index = postQueue.indexOf(importantPost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment