# Optional argument in Set Function [duplicate]

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. *)

• reference.wolfram.com/language/ref/Default.html – egwene sedai Jan 23 at 15:18
• @egwenesedai That does not help. – LBogaardt Jan 23 at 17:11
• ok, noticed that this may not be a good option here. I would avoid Set and use the proved-to-be-working SetDelayed unless there's a strong reason for not using that. Found a possible duplicate here, notice that answer still uses :> (RuleDelayed) – egwene sedai Jan 23 at 18:39
• Yes, that's a duplicate, thanks. Unfortunately, not a satisfying answer... – LBogaardt Jan 24 at 8:51