Dart double operator-less-than
Syntax & Examples


double.operator-less-than operator

The relational less than operator compares the given numeric value with another numeric value and returns true if the first value is less than the second value; otherwise, it returns false.


Syntax of double.operator-less-than

The syntax of double.operator-less-than operator is:

operator <(num other) → bool

This operator-less-than operator of double relational less than operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe numeric value to compare with


✐ Examples

1 Example with positive values

In this example,

  1. We create two positive numeric values numValue1 and numValue2 with values 10 and 5 respectively.
  2. We then use the less than operator < to compare numValue1 with numValue2.
  3. We print the comparison result to standard output.

Dart Program

void main() {
  num numValue1 = 10;
  num numValue2 = 5;
  bool isLessThan = numValue1 < numValue2;
  print('Is $numValue1 less than $numValue2: $isLessThan');
}

Output

Is 10 less than 5: false

2 Example with mixed positive and negative values

In this example,

  1. We create two numeric values numValue1 and numValue2 with values 3.5 and 6 respectively.
  2. We then use the less than operator < to compare numValue1 with numValue2.
  3. We print the comparison result to standard output.

Dart Program

void main() {
  num numValue1 = 3.5;
  num numValue2 = 6;
  bool isLessThan = numValue1 < numValue2;
  print('Is $numValue1 less than $numValue2: $isLessThan');
}

Output

Is 3.5 less than 6: true

3 Example with negative values

In this example,

  1. We create two negative numeric values numValue1 and numValue2 with values -8 and -3 respectively.
  2. We then use the less than operator < to compare numValue1 with numValue2.
  3. We print the comparison result to standard output.

Dart Program

void main() {
  num numValue1 = -8;
  num numValue2 = -3;
  bool isLessThan = numValue1 < numValue2;
  print('Is $numValue1 less than $numValue2: $isLessThan');
}

Output

Is -8 less than -3: true

Summary

In this Dart tutorial, we learned about operator-less-than operator of double: the syntax and few working examples with output and detailed explanation for each example.