Closed ASH-Michael closed 6 years ago
I think that blockless is fine, if it is on one line:
if (iceCream > vegetables) return true;
This keeps it terse but also is a signal to anyone adding more statements that they will need to add a block.
Like the ternary operator for conditionals? I would agree with that. I could buy off on blockless if it is written in a single line.
Seeing a blockless pattern on 2 lines is a visual speedbump for me.
Agreed upon standard: If you have a condition with only 1 statement, it can either be written with curly braces or written as a single line.
//good
if (condition) {
statement;
}
if (condition) statement;
//bad
if (condition)
statement;
are we allowed to do something like this?
condition ? true : false
@ashjackguo yes, but it's been unwritten. do you want to open a separate issue so we can confirm/educate in our meeting?
@ASH-Anthony Sure, I'll open a new issue for that!
I thought we already had a standard for this, but I am not able to find it in our standards repo.
or