The isLess() method checks if one number is less than another or not.
Example
isLess() Syntax
The syntax of the isLess() method is:
num.isLess(than: otherNumber)
Here, num is a number.
isLess() Parameters
The isLess() method takes one parameter
otherNumber- the value to test
isLess() Return Values
The isLess() method returns boolean value
true- ifnumis less ofotherNumberfalse- ifnumis greater thanotherNumber
Example 1: Swift Double isLess()
Output
false true false
Here, since 4 is not less than 2, the isLess() method returns false. However, 2 is less than 4, the method returns true.
Lastly, since 210 is multiple of 110, the method returns false.
Example 2: Using if…else With isLess()
Output
The condition is true
Here, since 88 is less than 88.2, the code inside the if block is executed.