6. Dart - Lists (Arrays)
Defining a list:
List alistname = ['bob', 'todd', 'dad'];
print(alistname);
print(alistname[0]); // indexing
Defining a specific list type:
List<String> alistname = ['bob', 'todd', 'dad'];
List<int> alistage = [30,50,60];
// use arrow brackets to define types.
Editing a list with built-in methods:
alistname.add("mary");
alistname.remove("todd");
// if a list is not defined to a specific type, then you can add any type to it.
Comments
Post a Comment