Like others, your code works just fine on its own. If you get the expected error declaration, you can write code inside your class as follows:
class myClass{
let CirclePoints = 84
var circlePoint = 0
for circlePoint in 0..<CirclePoints {
}
}
You can declare and set variables in the scope of the class, but any other logic must go inside the methods. If you want the for loop to be executed when you instantiate the class, you can put it in the init method of the class.
class myClass{
let CirclePoints = 84
var circlePoint = 0
init(){
for circlePoint in 0..<CirclePoints {
}
}
}
source
share