I want to rewrite the below code to use the conditional operator:
if indexPath.row == 0 {
cell.indentationLevel = kIndentFDA
} else {
cell.indentationLevel = kIndentCompleted
}
But when I write this:
indexPath.row == 0 ? cell.indentationLevel = kIndentFDA : cell.indentationLevel = kIndentCompleted
I get this compiler warning:
"Cannot assign to immutable expression of type 'Int'"
I don't know what the warning it but it probably can't figure out the order to apply the operators. This should work.
cell.indentationLevel = indexPath.row == 0 ? kIndentFDA : kIndentCompleted