1
0
forked from Mirror/wren

List; add swap(index0, index1)

This commit is contained in:
ruby0x1
2020-12-03 13:17:53 -08:00
parent 62009870a8
commit 38f50fe091
3 changed files with 36 additions and 0 deletions

9
test/core/list/swap.wren Normal file
View File

@ -0,0 +1,9 @@
var list = [0, 1, 2, 3, 4]
list.swap(0, 3)
System.print(list) // expect: [3, 1, 2, 0, 4]
list.swap(-1, 2)
System.print(list) // expect: [3, 1, 4, 0, 2]
list.swap(8, 0) // expect runtime error: Index 0 out of bounds.