Reputation: 13761
I have this code:
let posState = positionState(pos)
if posState != .None {
if posState == .Off {
boardArray[pos.row][pos.column] == .On
} else {
boardArray[pos.row][pos.column] == .Off
}
}
The issue I'm having is that when I attempt to change the value of an element in boardArray
, nothing happens. Why does boardArray's element stay the same?
Upvotes: 0
Views: 47
Reputation: 42977
Its not ==
, use the assignment operator =
boardArray[pos.row][pos.column] = .On
Upvotes: 0
Reputation: 3205
You are using ==
rather than =
for assigning
let posState = positionState(pos)
if posState != .None {
if posState == .Off {
boardArray[pos.row][pos.column] = .On
} else {
boardArray[pos.row][pos.column] = .Off
}
}
Upvotes: 2