After knowing the operator dart we are now going to a slightly more advanced stage. Namely if and else statements, this is a validation of a variable against a truth value, and the determining variable is very dynamic, so it's easy to understand.
Cheatsheet
In programming darts, there are several kinds the syntax used in the if else statement, please check the table below.
Syntax | Description |
if () | |
else if () | If condition if() does not run, and if the condition inside else if () is true (true), then the code inside will run |
else | If none of the other conditions are true, then the code inside else runs. |
? | If the previous code returns the value ben ar (true) then the next code will run. |
: | If the previous code used ? b> does not return a false value (false), then the code after : will run |
From the cheat sheet table above, the first 3 lines are regular statements, while lines 4 to 5 are inline conditions or you could say ternary.
Non Ternary Statement
Cheat sheet number 1 to 3.
example code.
void main(){
int number = 3;
if(number
result is
Odd
Ternary Statement
Cheat sheet number 3-5
example code
void main(){
int number = 3;
Result string = number
The result is
Odd