# What is the usefulness of adding a colon ":" to arguments in the declaration of a function?

I'm studying a code with the following function declaration :

FindChain[ x:__ ,y_?FindChainQ,z:__] := { {x},y,{z} }

What is the meaning of the colon ":" after the arguments x and z ?

What would be the diference(s) with this declaration (without the colons) :

FindChain[ x__,y_?FindChainQ,z__] := { {x},y,{z} }

Thank you,

• Check the documentation of SetDelayed. Jul 27 at 17:37
• Check the documentation for Pattern too. It says: The form s_ is equivalent to s:_ Similarly ... s__ to s:__. You can see this by doing FullForm[s__] and FullForm[s : __] . The purpose of it is a shorthand so you don't need to write the full Pattern and for when you have one symbol but a complex pattern object on the rhs. Jul 28 at 12:38

It is useful when your pattern does not start with _. Suppose your pattern is a list of integers,
total[list : {__Integer}] := Total[list]
total[___] := $Failed  Or a variable that can be true or false: func[arg:(True | False)] := If[arg, foo, bar] func[___] :=$Failed

A colon is useful to name a filter with the following syntax: name:filter. For example, polarPlot[r_, domain:{t_, tmin_, tmax_}]:=ParametricPlot[{r Cost[t], r Sin[t]}, domain] domain specifies a list of 3 éléments.
It can be useful also to factor a filter as r_Integer|r_Rational in r:(_Integer,_Rational)