Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark Houston
11,782 PointsType '(withRange: Int) -> [Point]' does not conform to protocol 'SequenceType'
I keep getting this error:
Type '(withRange: Int) -> [Point]' does not conform to protocol 'SequenceType'
on my code even though mine is exactly the same as Pasan's. Anyone know why?
Here's the block of code that is generating the error:
func fireAtEnemy (enemy: Enemy) {
if inRange(self.position, range: self.range, target: enemy.position) { while enemy.life > 0 {
enemy.decreaseHealth(self.strength)
print("Enemy vanquished!")
}
} else {
print("darn! the enemy is out of range")
}
}
func inRange(position: Point, range: Int, target: Point) -> Bool {
let availablePositions = position.surroundingPoints
(attackRange: range)
for point in availablePositions {
if (point.x == target.x) && (point.y == target.y) {
return true
}
}
return false
}
}
Lionel Coelho
1,206 PointsLionel Coelho
1,206 PointsHey did you figure this one out? I'm getting the same error but for this line of code
for point in availablePositions {
Error: Type '(Int) -> [Point]' does not conform to protocol 'Sequence'