Created
October 18, 2022 18:49
-
-
Save Simpler1/bcba709058741eba73155faa35a95c60 to your computer and use it in GitHub Desktop.
Dart Lists
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() { | |
final List list1 = ['zero', 'one', 'two', 'three']; | |
final List list2 = list1; // <- Create a new reference to the same list | |
list2[1] = 'five'; | |
print('$list1 $list2'); | |
final List list3 = ['nine', 'ten', 'eleven']; | |
final List list4 = List.from(list3); // <- Create a brand new list | |
list4[1] = 'twenty'; | |
print('$list3 $list4'); | |
// Lists should be final even though their contents can change. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment