Created
July 7, 2019 10:14
-
-
Save nikli2009/c4be2b118d4ed58b0d8ebd041b38cda4 to your computer and use it in GitHub Desktop.
Dart Ternary Operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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