String comparison: Difference between revisions

m
m (Using Ada.Strings.Equal_Case_Insensitive now.)
Line 1:
{{task|Basic Data Operations}}{{basic data operation}} [[Category:Basic language learning]]The task is to demonstrate how to compare two strings from within the language and how to achieve a lexical comparison. The task should demonstrate[[Category:Simple]]
The task is to demonstrate how to compare two strings from within the language and how to achieve a lexical comparison.
 
The task should demonstrate:
* Comparing two strings for exact equality
* Comparing two strings for inequality (i.e., the inverse of exact equality)
Line 18 ⟶ 20:
 
=={{header|Ada}}==
Ada uses the usual comparison operators ("=" for equality, "/=" for not being equal, ect.) for strings. One uses the same comparison operators to compare variables of other types (integers, floating point numbers, ect.). But, as Ada is strongly typed, comparing two objects of different type is not possible. To compare, say, a string and an integer, one would need to call an explicit type conversion for one of these objects.
But, as Ada is strongly typed, comparing two objects of different type is not possible.
To compare, say, a string and an integer, one would need to call an explicit type conversion for one of these objects.
 
String comparisons are case sensitive. Case insensitive comparisons have to use some conversion operation, such as Ada.Characters.Handling.To_Lower from the standard library, cf. [[http://rosettacode.org/wiki/String_case#Ada]]
Anonymous user