Is this some sort of implied if statement?short armed = 2 == (uint8_t) cbuf[19];

I am using some GitHub code and feel obglated to at lease try to understand what I'm using. In doing so I came across the below statement:

short armed = 2 == (uint8_t) cbuf[19];

I've searched the internet and can find no reference to anything similar. I expect it is a combined statement but have not clue what it means.

Anybody help?

Thanks
John

It sets a variable named “armed” to (2==(uint8_t) cbuf[19])

So it will be set to either true (1) or false (0) depending on whether byte 19 of cbuf (cast to an 8-bit unsigned int) is equal to 2.

There's an implied test between the value of cbuf[19] and the constant 2. armed takes the value 1 if true, 0 otherwise.

Thank you both. I understand. I would have been more clear to me if they used parens (though not needed).

I now will remember == takes precedence over =

John

Also bear in mind that '= ' as an operator is lowest on the precedence ladder 2nd only to the sequential evaluation operator (,) and is parsed/evaluated right-to-left. This means that everything to the right of '=' gets evaluated before the assignment.