List.addStart Method

Adds a value to the start of the list.

Syntax

public anytype addStart(anytype element)

Run On

Called

Parameters

  • element
    Type: anytype
    The value to add to the start of the list.

Return Value

Type: anytype
The value added to the list.

Remarks

Elements can be added to the end of the list by using the List.addEnd method.

Examples

The following example creates a list of integers, adds the values 1 and 2 to the end of the list, and then adds the value 3 to the start of the list. The values that are returned by the List.toString method are {3, 1, 2}.

{ 
    // Create a list of integers 
    list il = new List(Types::Integer); 
  
    // Add some elements to the list 
    il.addEnd(1); 
    il.addEnd(2); 
    il.addStart(3); 
  
    // Print a description of the list. 
    print il.definitionString(); 
    print il.toString(); 
    pause; 
}

See Also

List Class

List.addEnd Method

ListIterator.insert Method