As int,double, string override ==operator,does that have anything to do with identity? As they always are identical if they are compared with variables having same value and data type as theres
As int,double, string override ==operator,does that have anything to do with identity? As they always are identical if they are compared with variables having same value and data type as theres
Comparing number and string containing number
Strings can't equal to numbers even if the look the same. We first need to convert the string to an int and only then will they be equal.
void main() {
var x = 23;
var y = "23";
if (x == y)
print("string and int are not equal");
if (x == int.parse(y))
print("Converted string equals to int");
if (x.toString() == y)
print("Int converted to string also works");
}
Immutable Data Patterns in Dart and Flutter explains the Immutable data constructs in depth.