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

Popular posts from this blog

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

20. Data Analytics - Analyze Data to Answer Questions - Week 1

3. Algorithms - Selection Sort