Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 10, 2022 01:08 pm GMT

Arduino-conditional operator ? :

This might sound surprising but after close to 2 years working in the IoT field, I am yet to fully understand the ternary operator. Today I was forced by a project I am doing to read and understand it. So here is what I understood.

The ternary operator is some kind of conditional statement.

relayState ? Relay_ON : Relay_OFF
This means that if relay state returns true, turn on the relay, else turn it off.

a>b ? a : b
If a is greater than b, return a else return b.

Simple as that.


Original Link: https://dev.to/3stherm/arduino-conditional-operator--2gl2

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To