Default

Default[f]
gives the default value for arguments of the function f obtained with a pattern object.

Default[f, i]
gives the default value to use when appears as the i^(th) argument of f.

Default[f, i, n]
gives the default value for the i^(th) argument out of a total of n arguments.

Default[f, ...]=val
defines default values for arguments of f.

DetailsDetails

  • represents an optional argument to a function, with a default value specified by Default.
  • The necessary values for Default[f] must always be defined before is used as an argument of f.
  • Values defined for Default[f] are stored in DefaultValues[f].

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

Define 0 to be the default argument for a function :

In[1]:=
Click for copyable input
Out[1]=

represents an argument that can be omitted:

In[2]:=
Click for copyable input
Out[2]=

If the second argument is omitted, the default value of 0 is used instead:

In[3]:=
Click for copyable input
Out[3]=

If both arguments are omitted, both are taken to have the default value 0:

In[4]:=
Click for copyable input
Out[4]=
New in 1
New to Mathematica? Find your learning path »
Have a question? Ask support »