var x = 10
for index in 1 ... 20 {
let y = index * x--
}
I'm studying using iPad Pro's Playground. I played the same chord as the example Unary operator '--' cannot be applied to operands of type '@lvalueInt'. That's what it says. Please let me know the solution.
swift-playground swift
In Swift3, the --
operator and the ++
operator are missingYes, I think you copied the old example. We solved it using the -+
operator.
var x = 10
for index in 1 ... 20 {
x -= 1
let y = index * x
print(y)
}
Press the [Do] button to press the next code.
9
16
21
24
25
24
21
16
9
0
-11
-24
-39
-56
-75
-96
-119
-144
-171
-200
Is it correct if it's printed out like this?
© 2024 OneMinuteCode. All rights reserved.