Contents

Roo

Array.delete_at!()

Deletes the object at the specified index. Indexes are zero-based. If the index is negative a runtime error will be raised. If the index is out of range then Nothing is returned, otherwise the deleted object is returned.

array.delete_at!(index as Number) as Object

Parameters

  • index. Integer Number object. The zero-based index of the object to remove from the array

Returns

  • Returns the removed object
  • If index is >= 0 but out of range, Nothing is returned

Example

var x = ["a", "b", "c", "d"]
var y = x.delete_at!(1)
print(x) # => ["a", "c", "d"]
print(y) # => "b"

y = x.delete_at!(1)
print(x) # => ["a", "d"]
print(y) # => "c"

y = x.delete_at!(10)
print(x) # => ["a", "d"]
print(y) # => Nothing