Created with <3 with dartpad.dev.
Created
December 12, 2023 16:08
-
-
Save BEAUBastien/c667c7cbf5f56601a952ed1fcd863aeb to your computer and use it in GitHub Desktop.
astonishing-dart-5627
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
List<String> liste1 = ["France", "Italie", "Espagne", "Portugal"]; | |
List<String> liste2 = ["Suède", "Danemark", "Pays-Bas", "Belgique"]; | |
print ("Liste 1: ${liste1}"); | |
print ("Liste 1: ${liste2}"); | |
List<String> tPays = liste1; | |
print("Le nombre d'éléments dans tPays est : ${tPays.length}"); | |
tPays.add("Grèce"); | |
tPays.insert(tPays.length, "Suisse"); | |
tPays.insert(2, "Allemagne"); | |
tPays.removeAt(0); | |
tPays.removeAt(2); | |
tPays.addAll(liste2); | |
tPays.sort(); | |
tPays.sort((a, b) => b.compareTo(a)); | |
tPays.sort((a, b) => a.length.compareTo(b.length)); | |
List<int> longueurs = tPays.map((v) => v.length).toList(); | |
print("Liste des pays : ${tPays}"); | |
// Afficher la liste des longueurs | |
print("Liste des longueurs : $longueurs"); | |
print("Le nombre d'éléments dans tPays est : ${tPays.length}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment