list.GetForEdit

From GMod Wiki

Jump to: navigation, search
Function
Syntax list.GetForEdit( String name )
Where is this used?
Description:

Returns the named list. This function returns the actual list, unlike list.Get which returns a copy.

Use this function to get the list for direct editing.
Returns: Table
Part of Library: list
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=List.GetForEdit]List.GetForEdit [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionAdds 2 items to the list, gets it for editing and replaces the second item, then prints it into the console.
Used onNewerShared.png
Code
 
list.Add( "myList", "Hello" )
list.Add( "myList", "Hello" )
local list_of_stuff = list.GetForEdit("myList")
list_of_stuff[2] = "World"        // replace the second item
PrintTable( list_of_stuff )
 
Output
1 = Hello
2 = World


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox