Use [] to find tag! Example: [flutter, javascript]

Dart Basic Programming
Dart Basic Programming

Chapter 7

If Else Statement

remove_red_eye 2130 Times
spellcheck 202 Words, 1267 Characters

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.


If the condition is true (true), then the code inside will run

SyntaxDescription
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
elseIf 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

Next Article (For Loop)
Content Navigation