CMatrix:Remove


The Remove method removes the CMatrix member at row n, column m.

Syntax

value = CMatrix:Remove( nRow, nCol )

where

    nRow is the row index of the member to be removed.

    nCol is the column index of the member to remove.

    value is the returned value of the member that was removed. On failure, nil is returned.

  

This method removes the member at row n, column m. If removing the element leaves a row with zero columns, then the empty row is also removed.

The type of the returned value corresponds to whatever type was saved into the CMatrix at the specified index. This may be a number, string, or other quantity.

Example

The following script removes the member at index [10][8]:

M = CMatrix:new()

-- create a CMatrix object

M:Set( 5, 4, "s1" )

-- set member [5][4]

M:Set( 12, 40, "s2" )

-- set member [12][40]

M:Set( 20, 18, "s3" )

-- set member [20][18]

M:Set( 10, 120, "s4" )

-- set member [10][120]

Printf("N = %d", M:Members())

-- result: N = 4

v = M:Remove( 12, 40 )

-- remove member [12][40]

Printf("N= %d, v='%s'",M:Members(),v)

-- result: N = 3, v='s2'

Related Topics

RemoveRow

Members

CMatrix class