“Dartunterschied zwischen list.of und list.from” Code-Antworten

Dartunterschied zwischen list.of und list.from

// The important difference between the from and of methods are that the
// latter have type annotations and the former do not.
// Since Dart generics are reified and Dart 2 is strongly typed,
// this is key to both ensuring the List/Map is correctly constructed:

List<String> foo = new List.from(<int>[1, 2, 3]); // okay until runtime.
List<String> bar = new List.of(<int>[1, 2, 3]); // analysis error

// And ensuring that the types are inferred correctly:
var foo = new List.from(<int>[1, 2, 3]); // List<dynamic>
var bar = new List.of(<int>[1, 2, 3]); // List<int>
nidal bakir

Dart finden Unterschied zwischen Listen

List<double> first = [1,2,3,4,5,6,7];
List<double> second = [3,5,6,7,9,10];
List<double> output = [];

first.forEach((element) {
    if(!second.contains(element)){
    output.add(element);
}
});

//at this point, output list should have the answer
SeriousMonk

Ähnliche Antworten wie “Dartunterschied zwischen list.of und list.from”

Fragen ähnlich wie “Dartunterschied zwischen list.of und list.from”

Weitere verwandte Antworten zu “Dartunterschied zwischen list.of und list.from” auf Dart

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen