Skip to content

Instantly share code, notes, and snippets.

@superlopuh
Created June 22, 2015 00:44
Show Gist options
  • Save superlopuh/9d2a346c2f6bb02583a5 to your computer and use it in GitHub Desktop.
Save superlopuh/9d2a346c2f6bb02583a5 to your computer and use it in GitHub Desktop.
Written as an attempted solution to Brent Simmons's blog post.
// Written by Alexandre Lopoukhine
protocol Value: Equatable {}
protocol Smashable {
typealias SmashValue
func valueBySmashingOtherValue<T: Value>(value: T) -> SmashValue
}
struct Bar: Value {
}
func ==(lhs: Bar, rhs: Bar) -> Bool {
return true
}
struct Foo {
typealias SmashValue = Bar
func valueBySmashingOtherValue<T: Value>(value: T) -> Bar {
return Bar()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment