Remove property: Difference between revisions
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}}} | ||
|name=remove_property | |||
|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> | |||
<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> | |||
|code1={{CodeSample | |||
|title=Code Samples | |||
|description=Remove a property named <code>myPref</code> and print its previous value. | |||
|code= | |||
<syntaxhighlight lang="d"> | |||
print( "Removed myPref, old value was " + remove_property( "myPref" ) ); | |||
</syntaxhighlight> | |||
|moreinfo= | |||
}} | }} | ||
|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_property( string prop, boolean? global )
- Removes or resets a property and returns its previous value.
- prop: Property name
- global: If
true
, removes a global property. Iffalse
, 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" ) );