-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList.dart
32 lines (28 loc) · 819 Bytes
/
List.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//A list is an organized collection of items.
//In several programming languages,
//the idea of an array is equivalent to Dart's List data type.
void main(List<String> args) {
const names = ['Python', 'Dart', 'Web', 'DataBase'];
for (final name in names) {
print(name);
}
print('..................');
for (final name in names.reversed) {
//Reversed function is used to reverse
//from last to the top
print(name);
}
print('.................');
if (names.contains('Dart')) {
//Find the value in a list [Contains function]
print('Dart is in List');
}
print(names[0]);
print(names[1]);
print(names[2]);
print('..........');
names.sublist(1).forEach(print); //Start & end Values
print('------------');
names.sublist(1, 2).forEach(print);
print('-----------');
}