This compiles in Dart:
var data = ["abcd", 34, "ef", false];
int n = data[1];
print(n*2); // -> 68
I thought that list elements should be all of same type. And there is not implicit conversion from int to string or from bool to string in A):
print(data[1] is int); // -> true
print(data[3] is bool); // -> true
print(data[1] is String); // -> false
EDIT: as Mattia pointed out the real error in the following lines is not related to swapping elements in the list initializatione but to copy/paste from A) to B) leaving the same index ([1])
And this does not compile ("abcd" swapped with 34):
var data = [34, "abcd", "ef", false]; // -> type error
int n = data[1]; //EDIT: this is a non sense, should be data[0] (no error generated)
print(n*2);
Why? Some sort of substitution principle at work?