Skip to content

Instantly share code, notes, and snippets.

@jakebromberg
Created December 21, 2016 17:34
Show Gist options
  • Save jakebromberg/10ed0d731fda82f5e200a3ab6af51329 to your computer and use it in GitHub Desktop.
Save jakebromberg/10ed0d731fda82f5e200a3ab6af51329 to your computer and use it in GitHub Desktop.
import Foundation
protocol Identifiable {
associatedtype IdentifierType : Equatable
var id : IdentifierType { get }
}
struct Activity : Identifiable {
let id : Int
}
struct Thumbnail : Identifiable {
let id : Int
}
typealias Identifier<T: Identifiable> = T.IdentifierType
struct Cuepoint {
let thumbnailId : Identifier<Thumbnail>
let activityId : Identifier<Activity>
}
let thumbnail = Thumbnail(id: 1)
let activity = Activity(id: 123)
let activityCuepoint = Cuepoint(thumbnailId: activity.id, activityId: thumbnail.id)
print(activityCuepoint.activityId == thumbnail.id) // 😒
print(activityCuepoint.thumbnailId == activity.id) // 😞
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment