In swift 2.2, We could mutate a struct or enum within a closure, when it was inside a mutating function. But in swift 3.0 its no longer possible. I get the following error>
Struct is value type. So when use as Model or ModelView, you can make up a closure with new Value to VC.
struct Point {
var x = 0.0, y = 0.0
mutating func moveBy(x deltaX: Double, y deltaY: Double) {
x += deltaX
y += deltaY
test { [x, y](a) -> Point in
// Get the Error in the below line.
return Point(x: Double(a), y: y)
}
}
mutating func test(myClosure: @escaping (_ a: Double) -> Point) {
self = myClosure(3)
}
}