Last active
December 4, 2017 17:58
-
-
Save SiarheiFedartsou/3203394547a10a2d7b7458d144b772e4 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
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