I cant set 2 variables to - each other and equal a third variable in swift I'm trying to make var1 - var2 == var3 work in swift but I get Result of operator '==' is unused
when I use ==
and when I use =
I get Cannot assign to value: binary operator returns immutable value
this is the code I'm working on.
var pices1 = 1
var pices2 = 1
var warmup: Int = 60
var nexx: Int = 60
func logic() {
if count < 10 {
warmup = 5
count - warmup == nexx
pices1 = 1
pices2 = 1
}
}
==
is for checking if two values are equal. =
is for assigning a new value to a variable.
Just like when you define a new variable, the destination is on the left and the new value is on the right.
var warmup: Int = 60
In your case, you'll want the following.
nexx = count - warmup
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.