Files
wren/test/list/remove_at.wren
T

28 lines
484 B
Plaintext
Raw Normal View History

2013-11-27 10:20:32 -08:00
var a = [1, 2, 3]
a.removeAt(0)
2014-01-05 12:27:12 -08:00
IO.print(a) // expect: [2, 3]
2013-11-27 10:20:32 -08:00
var b = [1, 2, 3]
b.removeAt(1)
2014-01-05 12:27:12 -08:00
IO.print(b) // expect: [1, 3]
2013-11-27 10:20:32 -08:00
var c = [1, 2, 3]
c.removeAt(2)
2014-01-05 12:27:12 -08:00
IO.print(c) // expect: [1, 2]
2013-11-27 10:20:32 -08:00
// Index backwards from end.
var d = [1, 2, 3]
d.removeAt(-3)
2014-01-05 12:27:12 -08:00
IO.print(d) // expect: [2, 3]
2013-11-27 10:20:32 -08:00
var e = [1, 2, 3]
e.removeAt(-2)
2014-01-05 12:27:12 -08:00
IO.print(e) // expect: [1, 3]
2013-11-27 10:20:32 -08:00
var f = [1, 2, 3]
f.removeAt(-1)
2014-01-05 12:27:12 -08:00
IO.print(f) // expect: [1, 2]
2013-11-27 10:20:32 -08:00
// Return the removed value.
2014-01-05 12:27:12 -08:00
IO.print([3, 4, 5].removeAt(1)) // expect: 4