Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

makeTable

makeTable( 
S_name 
[ g_default_value ] 
) 
=> o_table

Description

Creates an empty association table.

Arguments

S_name

Print name (either a string or symbol) of the new table.

g_default_value

Default value to be returned when references are made to keys that are not in the table. If no default value is given, the system returns unbound if the key is not defined in the table.

Value Returned

o_table

The new association table.

Examples

If you specify a default value when you create the table, the default value is returned if a nonexistent key is accessed.

myTable = makeTable("atable1" 0)   
=> table:atable1
myTable[1]                         
=> 0

If you do not specify a default value when you create the table, the symbol unbound is returned if an undefined key is accessed.

myTable2 = makeTable("atable2")   
=> table:atable2
myTable2[1]                       
=> unbound

You can refer to and set the contents of an association table with the standard syntax for accessing array elements

myTable[1] = "blue"               
=> blue
myTable["two"] = '(r e d)         
=> (r e d)
myTable['three] = 'green          
=> green
myTable['three]                   
=> green

Related Topics

declare

Association Tables


Return to top
 ⠀
X