3 ms·
The first one would place 4 at the start of the array. So would the second one. If you did the first, then the second one, two 4s would be placed at the start.
by humbugtheman 3y ago
The first one would place 4 at the start of the array. So would the second one.
If you did the first, then the second one, two 4s would be placed at the start.
- layer8 3y agoBut arrays start at -1. How would that work?
- humbugtheman 3y agoYou can insert items before the start
- layer8 3y agoSo it’s not invariably true that arrays start at -1? They only start at -1 after an array literal assignment? You need to update the language description! ;)
- barnabee 3y agoPerhaps they start at -1 and proceed in both directions
- cdcarter 3y agoconst var scores = [3, 2, 5]! scores[0.5] = 4 print(scores) //[3, 2, 4, 5]! scores[-2] = 10 print(scores) //[10, 3, 2, 4, 5] print(scores[-1]) // 10 is how I interpret the spec, but I did not run this through the reference compiler yet.