-
-
Save xlc/c5fc00684416c919007e 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
struct Point3D { | |
var x: Int | |
var y: Int | |
var z: Int | |
} | |
protocol Point3DGenerator { | |
mutating func next() -> Point3D | |
} | |
struct Point3DGeneratorImpl { | |
var current: Point3D | |
init(_ cur: Point3D) { | |
current = cur | |
} | |
mutating func next() -> Point3D { | |
current.x += 2 | |
current.y -= 2 | |
current.z *= 2 | |
return current | |
} | |
} | |
func generateThree(generator: Point3DGenerator) -> (Point3D, Point3D, Point3D) { | |
return (generator.next(), generator.next(), generator.next()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment