Created
December 21, 2016 17:34
-
-
Save jakebromberg/10ed0d731fda82f5e200a3ab6af51329 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 | |
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