Clearing definitions works the same for symbols assigned values with Set (=) and functions defined with SetDelayed (:=).

Define a function or symbol

Define a function f:

In[1]:=
Click for copyable input

Find the definition of a function or symbol

Find the definition of f:

In[2]:=
Click for copyable input
  • You can also use Definition to get a symbol or a functions definition.

Clear the definition of a function or symbol

Clear the definition of f:

In[3]:=
Click for copyable input

The function f is no longer defined:

In[4]:=
Click for copyable input

Notes

If you redefine a function, using Clear beforehand will ensure that no unwanted definitions linger and cause potential problems.
Symbols whose values are assigned with Set (e.g. x=2) can be cleared with Unset (e.g. x=.).
Clear clears definitions, but not attributes, messages or defaults associated with symbols. Use ClearAll to clear all information associated with a symbol.
Clear and ClearAll leave the cleared symbol intact. Use Remove to remove the symbol completely:
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
The symbol x persists after Clear:
In[7]:=
Click for copyable input
Remove the symbol completely:
In[8]:=
Click for copyable input
In[9]:=
Click for copyable input