table.Inherit

From Garry's Mod
Jump to: navigation, search
 table.Inherit( )

Contents

Description

Copies any missing data from base to target, and sets the target's BaseClass member to the base table's pointer.

See table.Merge, which overrides existing values and doesn't add a BaseClass member.
See also table.Add, which simply adds values of one table to another.

BUG

Sub-tables aren't inherited. The target's table value will take priority.

Pull Request: #1304

Arguments

table target

Table to copy data to

Arguments

table base

Table to copy data from

Returns

table

Target

Examples

Example

Example of how this function works.

local table1 = { "A", "Golden" }
local table2 = { "Two", "Orange", "Apple" }
table.Inherit( table1, table2 )
PrintTable( table1 )

Output:

1	=	A
2	=	Golden
3	=	Apple
BaseClass:
		1	=	Two
		2	=	Orange
		3	=	Apple
Personal tools
Navigation