One liners in C++

I was wondering if there is any preference to simple one liners in C++. Simple of course being the most important part.

For example when setting bGameIsWon, I went with this instead of a lengthy if/else statement.

// Evaluate if number of bulls = word length and set it to bGameIsWon
bGameIsWon = (BullCowCount.Bulls == WordLength);
1 Like

Personally that’s preferred to the if/else system for a simple bool set. Ternary statements are also great if you have an if/else with one line in each section, and they don’t seem to be used that much.

Privacy & Terms