Clear: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>Eliteofdelete No edit summary |
||
Line 17: | Line 17: | ||
function_description=Clears the aggregate {{pspan|map}} of all its keys & data.| | function_description=Clears the aggregate {{pspan|map}} of all its keys & data.| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Tells you how many different items you have and then clears the map.| | |||
code= | |||
<syntaxhighlight> | |||
int[item] inventory = get_inventory(); | |||
print("You currently have "+count(inventory)+" different items in your inventory.", "blue"); | |||
clear(inventory); | |||
print("Now there are "+count(inventory)+" different items in the inventory map.", "blue"); | |||
</syntaxhighlight>| | |||
moreinfo= | |||
The clear command is most often used when doing lots of map manipulation, since maps only grow in size when assigning values to them. | |||
}}| | |||
see_also={{SeeAlso|count|file_to_map|map_to_file}}| | see_also={{SeeAlso|count|file_to_map|map_to_file}}| |
Latest revision as of 08:25, 11 January 2015
Function Syntax
- map is the aggregate to clear
Clears the aggregate map of all its keys & data.
Code Samples
Tells you how many different items you have and then clears the map.
int[item] inventory = get_inventory();
print("You currently have "+count(inventory)+" different items in your inventory.", "blue");
clear(inventory);
print("Now there are "+count(inventory)+" different items in the inventory map.", "blue");
The clear command is most often used when doing lots of map manipulation, since maps only grow in size when assigning values to them.