Skip to content

Instantly share code, notes, and snippets.

@krodak
Last active March 17, 2016 11:01
Show Gist options
  • Save krodak/a6bbbbd96e9ca464da38 to your computer and use it in GitHub Desktop.
Save krodak/a6bbbbd96e9ca464da38 to your computer and use it in GitHub Desktop.
class EventFeed: Hashable, Equatable {
var eventId = 0
var hashValue : Int { return eventId }
}
func ==(lhs: EventFeed, rhs: EventFeed) -> Bool {
return lhs.eventId == rhs.eventId
}
class PostUpload : EventFeed {
var postId : Int
override var hashValue : Int { return postId }
init(id: Int) {
postId = id
}
}
func ==(lhs: PostUpload, rhs: PostUpload) -> Bool {
return lhs.postId == rhs.postId
}
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