Top "Optional-parameters" questions

An optional parameter is one that a caller can include in a call to a function or method, but doesn't have to.

What does the construct x = x || y mean?

I am debugging some JavaScript, and can't explain what this || does? function (title, msg) { var title = title || 'Error'; var msg = …

javascript parameters optional-parameters or-operator
Default value of function parameter

1. int Add (int a, int b = 3); int Add (int a, int b) { } 2. int Add (int a, int b); int Add (…

c++ syntax optional-parameters
Groovy method with optional parameters

I would like to write a wrapper method for a webservice, the service accepts 2 mandatory and 3 optional parameters. To have …

groovy syntax optional-parameters
Why are C# 4 optional parameters defined on interface not enforced on implementing class?

I noticed that with the optional parameters in C# 4 if you specify an optional parameter on an interface you don,…

c# .net c#-4.0 interface optional-parameters
Set default value for DateTime in optional parameter

How can I set default value for DateTime in optional parameter? public SomeClassInit(Guid docId, DateTime addedOn = DateTime.Now???) { //Init …

c# datetime default optional-parameters
How to check whether optional function parameter is set

Is there an easy way in Python to check whether the value of an optional parameter comes from its default …

python function optional-parameters
How can I default a parameter to Guid.Empty in C#?

I wish to say: public void Problem(Guid optional = Guid.Empty) { } But the compiler complains that Guid.Empty is not …

c# c#-4.0 optional-parameters
VBA Function Optional parameters

I am calling a specific piece of code several times therefore I would like to use optional parameters. I can …

vba function optional-parameters
method overloading vs optional parameter in C# 4.0

which one is better? at a glance optional parameter seems better (less code, less XML documentation, etc), but why do …

c# .net c#-4.0 overloading optional-parameters