voltsarray[count] == voltage;
Are the rules different for this code or it should be = instead of ==. confused as usual.
voltsarray[count] == voltage;
Are the rules different for this code or it should be = instead of ==. confused as usual.
Your snippet is meaningless without context.
= is assignment. It changes the value of the thing on the left.
== is comparison. It returns true if the things on either side are equal.
It should be fairly obvious whether you're trying to compare to values or change the value of something.
The single = is an assignment operator. It assigns the value on the right to the variable on the left.
The double == is the equality operator. It compares the two values and returns true or false.
Without context, as AWOL points out, it is impossible to determine which you want to use.
PaulS:
The single = is an assignment operator. It assigns the value on the right to the variable on the left
. . .and evaluates true/false the result of the assignment
. . .and evaluates true/false the result of the assignment
No, it does not. It returns the VALUE assigned.
PaulS:
No, it does not. It returns the VALUE assigned.
This evaluates to true.
try it.
int a = 8;
if (a = 0){
Serial.println("This never gets printed");
}
if (a == 0) {
Serial.println("Even though the assignment was successful");
}
tnx