I have a decision tree of height 2:
const BOOL isVerticalAnimationRequired = YES;
const BOOL isArgumentEditorExpanded = YES;
const BOOL isSelectionLeftToRight = YES;
UITableViewRowAnimation argumentEditorAnimation;
if (isVerticalAnimationRequired)
{
argumentEditorAnimation = (isArgumentEditorExpanded) ? UITableViewRowAnimationTop : UITableViewRowAnimationBottom;
}
else
{
argumentEditorAnimation = (isSelectionLeftToRight) ? UITableViewRowAnimationLeft : UITableViewRowAnimationRight;
}
My problem is that the code is verbose. Ideally I would like to declare and set argumentEditorAnimation in one statement.
Are there any clever C style tips for handling situation like this?
I think I would not try to fold this into one expression for reasons of clarity, but if you must:
Alternatively, you can make your code more concise by dropping the
{}when they’re not needed.(Consider using shorter identifiers if you want to write these kinds of expressions. The long identifiers make the code verbose as well. E.g., drop the
isin your booleans.)