push

Summary

Adds an element to the end of the array.

Signatures

Click on a signature to select it and view its documentation.

Usage

public int push(T element)

Returns

The size of the array after the new element was added.

Parameters

element

The element to add to the end of the array.

Description

Adds an element to the end of the array and returns the size of the modified array.

This method mutates the array.

Examples

Basic Usage
1
2
3
4
5
6
import System;
 
int[] arr = [ 1, 2, 3, 4 ];
Console.log(arr.last()); // 4
arr.push(5);
Console.log(arr.last()); // 5

Share

HTML | BBCode | Direct Link