Link Search Menu Expand Document

Shift

Description

The Shift() method removes the first element from the array and returns that removed element. This method changes the length of the array.

Syntax

expression.Shift()

Parameters

None

Returns

Type
Variant
Description
The first element from the array.

Example

Public Sub ShiftExample()
    Dim result As String
    Dim MyArray As BetterArray
    Set MyArray = New BetterArray
    
    MyArray.Push "Banana", "Orange", "Apple", "Mango"
    result = MyArray.Shift
    ' expected output:
    ' result = "Banana"
    ' MyArray contains: "Orange", "Apple", "Mango"
End Sub

Inspiration

Back to Docs