Error: extensions must not contain stored properties in swift

53 Views Asked by At

How can I add more properties to exists struct? As following I tried to add property mass into exist struct (that coming from third party I cannot control it) but get an error extensions must not contain stored properties or

struct Planet {
  let name: String
}

extension Planet {
  var mass: String? 
}

let planet = Planet(name: "Earth")
0

There are 0 best solutions below