Skip to content

Instantly share code, notes, and snippets.

@nikli2009
Created July 7, 2019 10:14
Show Gist options
  • Save nikli2009/c4be2b118d4ed58b0d8ebd041b38cda4 to your computer and use it in GitHub Desktop.
Save nikli2009/c4be2b118d4ed58b0d8ebd041b38cda4 to your computer and use it in GitHub Desktop.
Dart Ternary Operator
void main() {
print(' '.padLeft(10,'-') + 'Ternary Operator' + ' '.padRight(10,'-'));
bool expression = true;
// Logic -> used in business logic of binary/simple strategy;
expression ? {
print(true)
} : {
print(false)
};
// inline style
expression ? print(true) : print(false);
// Flag -> used in UI mostly
print(' '.padLeft(10,'-') + 'Ternary Operator' + ' '.padRight(10,'-'));
double OrderPrice = 2000.00;
bool isExpensive = OrderPrice > 1500.00;
print(isExpensive);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment