Questions tagged [parameters]

Parameters are a type of variable used in a subroutine to refer to the data provided as input to the subroutine.

A parameter is an intrinsic property of a procedure, included in its definition. For example, in many languages, a minimal procedure to add two supplied integers together and calculate the sum total would need two parameters, one for each integer. In general, a procedure may be defined with any number of parameters, or no parameters at all. If a procedure has parameters, the part of its definition that specifies the parameters is called its parameter list.

There are two ways of passing parameters to a procedure (both of them may not be available in every programming language):

  • by value: the value of a variable (or constant, etc.) is passed to the procedure and the original variable cannot be affected by the code in the procedure.
  • by reference: the reference to a variable is passed to a procedure and the variable's value can be changed in the procedure.
22681 questions
83
votes
6 answers

Can I use identical names for fields and constructor parameters?

class C { T a; public: C(T a): a(a) {;} }; Is it legal?
Sergey Skoblikov
  • 5,811
  • 6
  • 40
  • 49
81
votes
12 answers

How do I submit a boolean parameter in Rails?

I'm submitting a parameter show_all with the value true. This value isn't associated with a model. My controller is assigning this parameter to an instance variable: @show_all = params[:show_all] However, @show_all.is_a? String, and if @show_all ==…
nfm
  • 19,689
  • 15
  • 60
  • 90
81
votes
4 answers

Display Parameter(Multi-value) in Report

Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving parameter.value option it gives error.
suni
80
votes
9 answers

Pass path with spaces as parameter to bat file

I have a simple bat script that copies files from an known directory to a directory given by the user. How can I pass the path (it might contain spaces) to my script and use it with the xcopy command? In my code i have the following :READ_PWA_PATH …
kjv
  • 11,047
  • 34
  • 101
  • 140
79
votes
4 answers

How can I programmatically include layout in Android?

I'm looking for a way to include a layout programmatically instead of using the XML tag include like in my example:
slama007
  • 1,273
  • 2
  • 18
  • 34
79
votes
16 answers

Extract parameters before last parameter in "$@"

I'm trying to create a Bash script that will extract the last parameter given from the command line into a variable to be used elsewhere. Here's the script I'm working on: #!/bin/bash # compact - archive and compact file/folder(s) eval…
user148813
  • 885
  • 1
  • 7
  • 11
76
votes
7 answers

Parameter evaluation order before a function calling in C

Can it be assumed a evaluation order of the function parameters when calling it in C ? According to the following program, it seems that there is not a particular order when I executed it. #include int main() { int a[] = {1, 2, 3}; …
corto
  • 2,657
  • 4
  • 21
  • 9
76
votes
3 answers

Params IEnumerable c#

Why cant I use an IEnumerable with params? Will this ever be fixed? I really wish they would rewrite the old libraries to use generics...
Dested
  • 6,294
  • 12
  • 51
  • 73
76
votes
7 answers

Passing function as a parameter in java

I'm getting familiar with Android framework and Java and wanted to create a general "NetworkHelper" class which would handle most of the networking code enabling me to just call web-pages from it. I followed this article from the…
Tumetsu
  • 1,661
  • 2
  • 17
  • 29
75
votes
7 answers

How to pass parameters or arguments into a Gradle task?

I have a Gradle build script into which I am trying to include Eric Wendelin's CSS plugin. It's easy enough to implement, and because I only want minification (rather than combining and gzipping), I've got the pertinent parts of the build script…
Nathan Russell
  • 3,428
  • 5
  • 30
  • 51
74
votes
8 answers

Good example of implicit parameter in Scala?

So far implicit parameters in Scala do not look good for me -- it is too close to global variables, however since Scala seems like rather strict language I start doubting in my own opinion :-). Question: could you show a real-life (or close) good…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
74
votes
7 answers

How do I modify a pointer that has been passed into a function in C?

So, I have some code, kind of like the following, to add a struct to a list of structs: void barPush(BarList * list,Bar * bar) { // if there is no move to add, then we are done if (bar == NULL) return;//EMPTY_LIST; // allocate space for…
Paul Wicks
  • 62,960
  • 55
  • 119
  • 146
74
votes
4 answers

Optional args in MATLAB functions

How can I declare function in MATLAB with optional arguments? For example: function [a] = train(x, y, opt), where opt must be an optional argument.
Yekver
  • 4,985
  • 7
  • 32
  • 49
72
votes
4 answers

C# - Is it possible to have null params?

public void Foo(params string[] values) { } Is it possible that values can ever be null, or will it always be set with 0 or more items?
michael
  • 14,844
  • 28
  • 89
  • 177
72
votes
2 answers

Which parameter set has been used?

I've used advanced parameter handling to support multiple parameter sets. Is there any pre-defined variable or way to determine which parameter set has been used to call the script? e.g. something like if($parameterSet -eq "set1") { ... } elseif…
D.R.
  • 20,268
  • 21
  • 102
  • 205