An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
January 10, 2022 01:08 pm GMT
Original Link: https://dev.to/3stherm/arduino-conditional-operator--2gl2
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To