I am getting error around using the self operator when running code from Chapter 3, p. 43. I THINK I have entered the code properly, but I am unsure if I am hitting another Swift 2.x - Swift 3.0 issue…?
//: Playground - noun: a place where people can play
import Cocoa
// METHODS allow you to add functionaliy to your data
// types. You can add methods to structures as well as classes
// and enums.
//
// INSTANCE METHODS operate within the context of a single
// instance of the type.
struct Vector {
var x:Double
var y:Double
init(){
self.init(x:0,y:0)
}
init(x: Double, y:Double) {
self.x=x
self.y=y
}
}
func vectorByAddingVector(vector: Vector) -> Vector {
return Vector (x: self.x + vector.x, // ERROR: Use of unresolved identifier 'self'
y: self.y + vector.y) // ERROR: Use of unresolved identifier 'self'
}
let gravity=Vector(x:0.0, y: 9.8)
gravity.x
gravity.y