ePrivacy and GPDR Cookie Consent by CookieConsent.com
menu

Dart string compareTO() method

Definition and usage

compareTo() method in dart strings is used for comparing two strings.
Case sensitivity matters in comparison to strings.
Ordering does not check for Unicode equivalence. 
 
Suppose we have two strings x and then, 
  • if y is a prefix of x then the result will be Positive.
  • if y is equivalent to x then the result will be Zero.
  • if y is in the middle of x or at the end of x then the result will be Negative.
  • if y is not present in x then the result will be Negative.

Example


Syntax

string.compareTo(other_string);

Parameter value

+---------------+-------------------------------------------------+
|   Parameter   |  Description                                    |
+---------------+-------------------------------------------------+
| other_string  | Required! This parameter is used as the string  |
|               | which is going to be compared.                  |
+---------------+-------------------------------------------------+

More technical details

+-------------+---------------------------------------------+
| Return type | This methd returns a integer type value     |
|             | which is either positive, negative or Zero. |
+-------------+---------------------------------------------+

Comments