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.


examples/dart-intro/equality.dart
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");
}