Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
if...else Statement | Conditional Statements
Introduction to Dart

if...else Statementif...else Statement

if...else Statement

An if can be followed by an optional else block. The else block will execute if the Boolean expression tested by the if block evaluates to false.

Example

dart

main.dart

In the example above, the age < 18, so the if code block hasn't been executed. The else code block executes when the if condition is false.

The else syntax is like the if syntax without a condition and parentheses ( )

Task

Write a condition for the if statement to check whether the variable is of type int.

num is int - correct condition

using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
      
dart

main.dart

Все було зрозуміло?

Секція 3. Розділ 2
course content

Зміст курсу

Introduction to Dart

if...else Statementif...else Statement

if...else Statement

An if can be followed by an optional else block. The else block will execute if the Boolean expression tested by the if block evaluates to false.

Example

dart

main.dart

In the example above, the age < 18, so the if code block hasn't been executed. The else code block executes when the if condition is false.

The else syntax is like the if syntax without a condition and parentheses ( )

Task

Write a condition for the if statement to check whether the variable is of type int.

num is int - correct condition

using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
      
dart

main.dart

Все було зрозуміло?

Секція 3. Розділ 2
some-alt