Clear

Clear[symbol1,symbol2,]

clears values and definitions for the symboli.

Clear["form1","form2",]

clears values and definitions for all symbols whose names match any of the string patterns formi.

Details

  • Clear does not clear attributes, messages, or defaults associated with symbols.
  • Clear allows abbreviated string patterns containing the following metacharacters:
  • *zero or more characters
    @one or more characters, excluding uppercase letters
    \\*, etc.literal *, etc.
  • Clear["context`*"] clears all symbols in a particular context.
  • Clear is HoldAll.
  • Clear does not affect symbols with the attribute Protected.

Examples

open allclose all

Basic Examples  (2)

Clear a variable:

Clear a function definition:

Scope  (4)

Clear values of variables:

Clear functions (downvalues):

Clear upvalues:

Clear several symbols:

Generalizations & Extensions  (2)

Clear all symbols in a given context:

Specify symbols to clear as string patterns:

Applications  (1)

Clear any old definitions before making new ones:

Properties & Relations  (2)

Clear does not remove defaults, options, or attributes:

Use ClearAll to clear everything:

Use =. to clear definitions with a particular left-hand side:

Clear all definitions:

Possible Issues  (1)

Protected symbols cannot be cleared:

Use Unprotect to clear definitions of protected symbols:

Neat Examples  (1)

Clear the definitions of all symbols in the current context:

Wolfram Research (1988), Clear, Wolfram Language function, https://reference.wolfram.com/language/ref/Clear.html.

Text

Wolfram Research (1988), Clear, Wolfram Language function, https://reference.wolfram.com/language/ref/Clear.html.

BibTeX

@misc{reference.wolfram_2021_clear, author="Wolfram Research", title="{Clear}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Clear.html}", note=[Accessed: 02-August-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_clear, organization={Wolfram Research}, title={Clear}, year={1988}, url={https://reference.wolfram.com/language/ref/Clear.html}, note=[Accessed: 02-August-2021 ]}

CMS

Wolfram Language. 1988. "Clear." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Clear.html.

APA

Wolfram Language. (1988). Clear. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Clear.html