This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

RuleDelayed

or
represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used.
  • You can apply rules using Replace.
  • The assignment specifies that the rule should be used whenever it applies.
  • You can use Condition to specify when a particular rule applies.
holds its right-hand side unevaluated:
The right-hand side is evaluated separately each time it is used:
holds its right-hand side unevaluated:
In[1]:=
Click for copyable input
Out[1]=
The right-hand side is evaluated separately each time it is used:
In[2]:=
Click for copyable input
Out[2]=
Increment each time is replaced:
Evaluate the StepMonitor expression separately each time it is to be used:
Generate a diagonal matrix with random elements:
evaluates when it is first entered; when it is used:
Module and With do not affect local variables of RuleDelayed:
Module effectively uses a renamed instance of :
By evaluating the arguments to RuleDelayed, local scoping is avoided:
New in 1 | Last modified in 3