The MatchParameters Object

The MatchParameters object is used to match to the parameters passed into functions.

Clauses in object definitions typically contain at least one MatchParameters object. For example, suppose we have a function named MyFn which contains the clause:

The term on the left-hand side is a MatchParameters object. If we execute this function on "x + y", (so we are executing MyFn[x + y]), then the expression that is actually processed is:

So the MatchParameters object is just a placeholder for a Match object that is populated with a parameter passed into the function call.

The MatchParameters object also works with functions with more than one parameter. So if MyFn2 is a two parameter function with the clause:

and we execute MyFn2[x, y-1], then the clause that is executed is: