Skip to content

Instantly share code, notes, and snippets.

@andrevidela
Last active January 7, 2019 14:38
Show Gist options
  • Save andrevidela/4e309b24060373e521152033519e3365 to your computer and use it in GitHub Desktop.
Save andrevidela/4e309b24060373e521152033519e3365 to your computer and use it in GitHub Desktop.
extension Additive where Self: TwoDimensions, Self.ComponentVal: Additive {
static var addId: Self {
return Self.make2D(Self.ComponentVal.addId, Self.ComponentVal.addId)
}
static func + (lhs: Self, rhs: Self) -> Self {
return make2D(lhs.fst + rhs.fst, lhs.snd + rhs.snd)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment