The `isOdd` property in Dart returns true if and only if the integer is odd.
The syntax of int.isOdd property is:
bool isOdd
This isOdd property of int returns true if and only if this integer is odd.
int.isOdd returns value of type bool
.
In this example,
5
to the integer variable num1
.num1
is odd using the isOdd
property.void main() {
int num1 = 5;
bool result1 = num1.isOdd;
print('Is $num1 odd? $result1');
}
Is 5 odd? true
In this example,
8
to the integer variable num2
.num2
is odd using the isOdd
property.void main() {
int num2 = 8;
bool result2 = num2.isOdd;
print('Is $num2 odd? $result2');
}
Is 8 odd? false
In this example,
-3
to the integer variable num3
.num3
is odd using the isOdd
property.void main() {
int num3 = -3;
bool result3 = num3.isOdd;
print('Is $num3 odd? $result3');
}
Is -3 odd? true
In this Dart tutorial, we learned about isOdd property of int: the syntax and few working examples with output and detailed explanation for each example.