An optional argument is an argument which can be omitted, eventually being replaced by a default value, where an argument is an actual value passed to a function, procedure, or command line program.
Questions tagged [optional-arguments]
223 questions
0
votes
2 answers
check the order & validate arguments to shell script
I know similar questions may be asked on this ,but I am a total newbie to shell scripting & not finding help (may be I am not able to understand the technicalities). I have a simple question:
I have a simple script (testscript.sh) which needs 3…

AndroidGuy
- 1,270
- 4
- 15
- 32
-1
votes
1 answer
looping over optional arguments (strings) in python
I have lists of strings, some are hashtags - like #rabbitsarecool others are short pieces of prose like "My rabbits name is fred."
I have written a program to seperate them:
def seperate_hashtags_from_prose(*strs):
props = []
hashtags =…

Abijah
- 512
- 4
- 17
-1
votes
3 answers
Is there a way to explicitly call optional arguments in c++?
When I create a function such as:
int addThree(int x=1, int y=1, int z=1)
I want to call the function such that it uses the default arguments for x and z, but not y.
Some attempts have been addThree(5,,5) and addThree(5,NULL,5), but neither work…

nicky eyes
- 31
- 3
-1
votes
1 answer
Optional Arguments in an Expression Tree
I have (tried) to pass an expression of a call to a method that takes optional parameters and encountered the problem described in this Q&A. It came up in the context of a unit test.
Eric Lippert said that named argument support in expression trees…

Kit
- 20,354
- 4
- 60
- 103
-1
votes
1 answer
Optional params in Go?
I know that there aren't any optional params in the latest version of Go. But there are quite a lot cases when they are really helpful.
Consider oversimplified example:
func getFullName(firstName string, lastName string, maybeMiddleName func()…

Zazaeil
- 3,900
- 2
- 14
- 31
-1
votes
1 answer
C# Optional Arguments - for loop
I'm in the very early stages of learning C# and have hit a bit of a road block in that I can't wrap my head around some seemingly basic logic! I have the expected output value and just can't seem to marry it up to the input. Could someone step…

Rob P
- 65
- 1
- 2
- 7
-1
votes
2 answers
How to pass additional arguments on built-in Node.js function?
So, I'm going through the Node.js learnyounode tutorial (which is pretty fun), but I'm no stranger to javascript. One of the requests is to have the user write a program that accepts a directory and a file extension as arguments, and then proceeds…

Bob Smith
- 145
- 5
-1
votes
2 answers
function with multiple arguments in PHP
I'm starting to learn oop in php and i would like to know whats wrong with my method that accepts multiple arguments.
class Database
{
public function __call($method, $args)
{
if($method == 'insertData')
{
…

xRed
- 1,895
- 6
- 20
- 36
-2
votes
1 answer
How can I force the use of a default parameter value in C# (skip optional arguments)?
If I am using a method with multiple optional parameters, how can I call the method without specifying only one of the parameters, letting it use its default value?
Say I have method Foo with multiple optional parameters:
void Foo(string a, int b =…

DMX David Cardinal
- 599
- 2
- 7
- 19
-2
votes
2 answers
Using optional arguments in a function to reverse a range python 3
I need to use an optional argument to take a range and reverse it by using a main function to call the function containing the arguments. My output needs to have the original range, followed by the same list in reverse. I cannot figure out how to…

astute
- 57
- 5
-2
votes
5 answers
Passing Default and optional Arguments in Python
def fun( key=False,*var):
if key is False:
print(var)
return 0
print("Key is true")
return 0
fun(1,2,3)
I have not passed a value of key in fun(1,2,3). Hence the default value of key i.e. key=False. But the output is:
Key is…

Ayush Shridhar
- 115
- 4
- 11
-3
votes
1 answer
Trying to create this. Can someone assist?
Can someone assist with this query below?
In JavaScript, define a function makeCounter which takes one optional argument defining the intial value, start, with a default value of 0. The function should return an object containing keys that define 3…

Dhruvi
- 1
-3
votes
2 answers
Java's Optional Forces Itself or else I get an error
Why do I get an error if I don't use Optional (the IDE suggested I use Optional) as oppose to just using DemographicEntity demoEntity?
@Test
public void testFindDemographicsById() {
DemographicEntity demoEntity = demoRepo.findById(1l);…

coder3
- 357
- 1
- 3
- 14