Remove property: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Smelltastic
Created page with "{{ #vardefine:name|remove_property}}{{ #vardefine:return_type|void}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate..."
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|remove_property}}{{
|name=remove_property
#vardefine:return_type|void}}{{
|function1.return_type=string
|function1.description=Removes or resets a property and returns its previous value.
|function1.param1=prop
|function1.param1.type=string
|function1.param1.description=Property name
|function1.param2=global
|function1.param2.type=boolean
|function1.param2.optional=yes
|function1.param2.description=If <code>true</code>, removes a global property. If <code>false</code>, removes a user property. If omitted, this checks both user and global properties.
|description=<p>If the property has a default value, it will be reset to its default value instead.</p>


FunctionPage|
<p>This function was added in [https://kolmafia.us/threads/17892-add-a-bunch-of-ash-support-for-doing-interesting-things-with-properties-bool.21586/ r17892].</p>
name={{#var:name}}|
|code1={{CodeSample
 
  |title=Code Samples
function1={{Function|
  |description=Remove a property named <code>myPref</code> and print its previous value.
name={{#var:name}}|
  |code=
aggregate={{#var:aggregate}}|
<syntaxhighlight lang="d">
return_type={{#var:return_type}}|
print( "Removed myPref, old value was " + remove_property( "myPref" ) );
return_also={{#var:return_also}}|
</syntaxhighlight>
parameter1={{Param|string|prop}}|
  |moreinfo=
p1desc={{Pspan|prop}} is the property to remove.|
}}|
 
function2={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|string|prop}}|
parameter2={{Param|boolean|global}}|
p1desc={{Pspan|prop}} is the property to remove.|
p2desc={{Pspan|global}} if true, look for the property specifically in the global map. If false or not included will look at the user map.|
}}|
 
function_description=If {{Pspan|prop}} is a built-in property, resets to default. Otherwise, removes from the user map, or global if {{Pspan|global}} is true.|
 
see_also={{SeeAlso|Miscellaneous_Functions#Property_Functions}}|
}}
}}
 
|see_also={{SeeAlso/Property Functions}}
|cli_equiv=
|more_info=
|special=
|{{{1|}}}
}}</onlyinclude>
[[Category:Miscellaneous Functions]]
[[Category:Miscellaneous Functions]]

Latest revision as of 11:17, 23 December 2020

Function Syntax

string remove_propertystring prop, boolean? global )

Removes or resets a property and returns its previous value.
  • prop: Property name
  • global: If true, removes a global property. If false, removes a user property. If omitted, this checks both user and global properties.

If the property has a default value, it will be reset to its default value instead.

This function was added in r17892.

Code Samples

Remove a property named myPref and print its previous value.

print( "Removed myPref, old value was " + remove_property( "myPref" ) );

See Also

get_all_properties() | property_exists() | property_has_default() | property_default_value() | get_property() | set_property() | remove_property() | rename_property()