Optional arguments can be defined in SetDelayed (:=) Functions (see f1 below and here and here). However, how can one accomplish this in Set (=) Functions (see f2 and f3 below)?
f1[x_:0]:=x
f1[4] (* 4 *)
f1[] (* 0 *)
f2=Function[{x},x]
f2[4] (* 4 *)
f2[] (* Function:fpct:Too many parameters in {x} to be filled from Function[{x},x][]. *)
f3=Function[{x:0},x] (* Function:flpar:Parameter specification {x:0} in Function[{x:0},x] should be a symbol or a list of symbols. *)
Setand use the proved-to-be-workingSetDelayedunless there's a strong reason for not using that. Found a possible duplicate here, notice that answer still uses:>(RuleDelayed) – egwene sedai Jan 23 '19 at 18:39