# Default value behaves differently when used in Function and when used with Cases

Consider this example:

 Cases[{4, x, 5 a , 6 x}, x_.*a_ :> x]

(*{1, 1, 5, 6}*)


It is clear that the _. took 1 as a Default value.

Now:

f[x_.] := {x} dose not work and _. Default value has to be user defined first

Default[f] = 0;
f[x_.] := {x}
f[]
(*{0}*)


It is little confusing that _. takes default value in some operation and has to be user defined with default value in other operation.

Any explanations?

Thanks

• The functions Times, Plus, Power have built-in default values (1, 0, and 1, respectively). – kglr Dec 29 '14 at 0:56
• Use DefaultValues[Times], DefaultValues[Plus] etc. to see this. Now try DefaultValues[f] before you have attached any default values to it, and you will see that f has no built-in default values. – C. E. Dec 29 '14 at 0:57
• Ok. Thanks. It is clear now:) – Basheer Algohi Dec 29 '14 at 1:05

Default[Times]

As you see, the DefaultValues for Times and Plus are already built in.