Skip to content

Instantly share code, notes, and snippets.

@SiarheiFedartsou
Last active December 4, 2017 17:58
Show Gist options
  • Save SiarheiFedartsou/3203394547a10a2d7b7458d144b772e4 to your computer and use it in GitHub Desktop.
Save SiarheiFedartsou/3203394547a10a2d7b7458d144b772e4 to your computer and use it in GitHub Desktop.
protocol Shape {
func accept<V: ShapeVisitor>(_ visitor: V) -> V.Result
}
struct Rectangle: Shape {
let width: Float
let height: Float
func accept<V: ShapeVisitor>(_ visitor: V) -> V.Result {
return visitor.visit(self)
}
}
struct Circle: Shape {
let radius: Float
func accept<V: ShapeVisitor>(_ visitor: V) -> V.Result {
return visitor.visit(self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment