Skip to content

Instantly share code, notes, and snippets.

@kateinoigakukun
Created February 22, 2018 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateinoigakukun/92fc9f5fd9a866032cd01a9ff11ae671 to your computer and use it in GitHub Desktop.
Save kateinoigakukun/92fc9f5fd9a866032cd01a9ff11ae671 to your computer and use it in GitHub Desktop.
こういうのを求めてる #CodePiece
protocol Nouns {}
protocol Verb {}
struct I: Nouns {}
struct Play: Verb, Nouns {}
struct Tennis: Nouns {}
struct Love: Verb {}
struct SVO<S: Nouns, V: Verb, O: Nouns> {
init(s: S, v: V, o: O) {}
}
let phrase1 = SVO(s: I(), v: Play(), o: Tennis())
let phrase2 = SVO(s: I(), v: Love(), o: Tennis())
let phrase3 = SVO(s: Play(), v: I(), o: Love()) // compile error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment