Quick help with the || operator

I cant get this statement to work. As soon as I include the || operator all strings are included. Ie. IF statement will run also when the item used returns "EXIT" and not only "SETUP" or "Set Boost Parametres".

if (used.item == "SETUP" || "Set Boost Parametres") //String comparison to set MenuUse behaviour
     {
           Serial.println("Menu DOWN & RIGHT");
           menu.moveDown();
           menu.moveRight();
     }

Thanks

Is this not what you are wanting to do?

  • notice the added code after the || used.item ==
if (used.item == "SETUP" || used.item == "Set Boost Parametres") //String comparison to set MenuUse behaviour
     {
           Serial.println("Menu DOWN & RIGHT");
           menu.moveDown();
           menu.moveRight();
     }

What type is used.item? Does that type actually have an equality operator that compares objects of that type?

@marklar And that's how easy 3 hours of fiddling about can be solved in 2 minutes :) Thanks a million. B

@PaulS I suppose so, since only one string comparison works. It was when I added the other strings that the problems started. It works now, but I still don't understand it properly. This code uses the menuBackend library. Does that mean that the type is declares by the library?