Questions tagged [default-parameters]

A default parameter is a function or method parameter that has a default value provided to it. If the user does not supply a value for this parameter, the default value will be used. If the user does supply a value for the default parameter, the user supplied value is used.

A default parameter is a function or method parameter that has a default value provided to it. If the user does not supply a value for this parameter, the default value will be used. If the user does supply a value for the default parameter, the user supplied value is used.

366 questions
0
votes
1 answer

Lightweight JavaScript Module for Optional/Default Parameters

Is there a JavaScript module that makes it easy to map arguments to parameters? Here is how I envision it working: var arguments = assignArguments(arguments, 'p1', 'p2', [{'p3': 0}, 'p4'], {'p5': 'unknown'}); Within a function, you would call…
Travis Parks
  • 8,435
  • 12
  • 52
  • 85
0
votes
2 answers

Is it OK to have a mutable default argument if it's annotated as immutable?

It is generally, for good reason, considered unsafe to use mutable default arguments in python. On the other hand, it is quite annoying to always have to wrap everything in Optional and do the little unpacking dance at the start of the function. In…
Hyperplane
  • 1,422
  • 1
  • 14
  • 28
0
votes
0 answers

Is it possible to have the values in default tuple/list parameters at same line, but have every parameter at newline?

I have an autogenerated file on which I run: autopep8 --in-place --aggressive --aggressive The problem is that for default tuples, they are separated to multiple lines, and I want each tuple on their own line. For instance: def function( …
Sombrero
  • 25
  • 5
0
votes
0 answers

Update parameter with default value in a bash script

I am new to bash scripting and struggle to update a parameter with a default value. I observe some of my optional parameters are not getting updated according to the user input. Below is the interesting part of my bash script. For instance, I set…
Barbara Gendron
  • 385
  • 1
  • 2
  • 16
0
votes
1 answer

Default parameters for methods of template class

Is there a way to provide default parameter values for methods of a template class? For example I have the following: template class A { public: A foo(T t); }; How should I modify this to give foo a default parameter of type T? For…
SolidSun
  • 2,149
  • 2
  • 23
  • 28
0
votes
1 answer

C2572 - When trying to include a function with a default parameter in another file, and then include this file in main

I am trying to build a small program in C++, to learn the preprocessor directives and how they actually work. The program is made up of 5 files: main.cpp, file1.h, file1.cpp, file2.h and file2.cpp In file1.h, I declared 1 function that has the…
X Y
  • 233
  • 1
  • 8
0
votes
0 answers

Optionally passing values via kwargs to inner functions with default parameters

I have a outer function foo that calls two inner functions, bar1 and bar2. Each inner function (bar) has default parameters. I'd like to be able to call foo and specify whichever parameters I want, and then use the inner function defaults for…
tmldwn
  • 435
  • 4
  • 13
0
votes
2 answers

JavaScript - Why i'm not able to pass a default parameter?

Insert here:

No one here