← Dart tutorial

Dart

Operators

Arithmetic (+ - * /), comparison (== != > <), and logical (&& || !) operators all work as you'd expect from other C-family languages.

Example: a boolean expression, printed with interpolation

void main() {
  int score = 85;
  bool passed = score >= 50 && score <= 100;
  print('Passed: $passed');
}
Passed: true

$passed inside a single-quoted string interpolates the variable directly, Dart's string interpolation works in both single and double-quoted strings, unlike some languages (PHP, for instance, only interpolates inside double quotes).

Example
void main() {
  int score = 85;
  bool passed = score >= 50 && score <= 100;
  print('Passed: $passed');
}
Output
Passed: true
Ready to go further?

These free tutorials are a preview of what a Code Secure Academy cohort covers, project work and all.

Explore our tracks

Cookie preferences

Choose what you're comfortable with. You can change this any time from the footer.

Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account