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
208
votes
9 answers

Is there a generic constructor with parameter constraint in C#?

In C# you can put a constraint on a generic method like: public class A { public static void Method (T a) where T : new() { //...do something... } } Where you specify that T should have a constructor that requires no…
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
201
votes
3 answers

URL matrix parameters vs. query parameters

I'm wondering whether to use matrix or query parameters in my URLs. I found an older discussion to that topic not satisfying. Examples URL with query params: http://some.where/thing?paramA=1¶mB=6542 URL with matrix params:…
deamon
  • 89,107
  • 111
  • 320
  • 448
197
votes
12 answers

Arguments or parameters?

I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world. What's the correct convention for their use?
Peanut
  • 18,967
  • 20
  • 72
  • 78
195
votes
5 answers

Using parameters in batch files at Windows command line

In Windows, how do you access arguments passed when a batch file is run? For example, let's say I have a program named hello.bat. When I enter hello -a at a Windows command line, how do I let my program know that -a was passed in as an argument?
APerson
  • 8,140
  • 8
  • 35
  • 49
194
votes
6 answers

How do I pass multiple parameters in Objective-C?

I have read several of the post about Objective-C method syntax but I guess I don't understand multiple names for a method. I'm trying to create a method called getBusStops with NSString and NSTimeInterval parameters and a return type of…
Atma
  • 29,141
  • 56
  • 198
  • 299
191
votes
7 answers

Passing a function with arguments as an argument?

Is it possible to pass a javascript function with arguments as an argument? Example: $(edit_link).click( changeViewMode( myvar ) );
Lucia
  • 4,657
  • 6
  • 43
  • 57
185
votes
1 answer

What is the purpose of static keyword in array parameter of function like "char s[static 10]"?

While browsing some source code I came across a function like this: void someFunction(char someArray[static 100]) { // do something cool here } With some experimentation it appears other qualifiers may appear there too: void someFunction(char…
dreamlax
  • 93,976
  • 29
  • 161
  • 209
182
votes
6 answers

How to pass argument to Makefile from command line?

How to pass argument to Makefile from command line? I understand I can do $ make action VAR="value" $ value with Makefile VAR = "default" action: @echo $(VAR) How do I get the following behavior? $ make action value value How about $make…
Meng Lu
  • 13,726
  • 12
  • 39
  • 47
179
votes
7 answers

How can query string parameters be forwarded through a proxy_pass with nginx?

upstream apache { server 127.0.0.1:8080; } server{ location ~* ^/service/(.*)$ { proxy_pass http://apache/$1; proxy_redirect off; } } The above snippet will redirect requests where the url includes the string "service" to…
Alex Luya
  • 9,412
  • 15
  • 59
  • 91
179
votes
3 answers

Proper usage of Java -D command-line parameters

When passing a -D parameter in Java, what is the proper way of writing the command-line and then accessing it from code? For example, I have tried writing something like this... if (System.getProperty("test").equalsIgnoreCase("true")) { //Do…
Ryan Berger
  • 9,644
  • 6
  • 44
  • 56
178
votes
11 answers

How to pass anonymous types as parameters?

How can I pass anonymous types as parameters to other functions? Consider this example: var query = from employee in employees select new { Name = employee.Name, Id = employee.Id }; LogEmployees(query); The variable query here doesn't have strong…
Saeed Neamati
  • 35,341
  • 41
  • 136
  • 188
177
votes
5 answers

Perform Segue programmatically and pass parameters to the destination view

in my app I've a button that performs a segue programmatically: - (void)myButtonMethod { //execute segue programmatically [self performSegueWithIdentifier: @"MySegue" sender: self]; } I would like to know if there is a way to reference the…
yassassin
  • 3,185
  • 6
  • 28
  • 31
175
votes
10 answers

Android set height and width of Custom view programmatically

I have created a custom view named Graphview . Here is the structure for the GraphView class. public class GraphView extends View { public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean…
dev_android
  • 8,698
  • 22
  • 91
  • 148
173
votes
11 answers

How do I pass a class as a parameter in Java?

Is there any way to pass class as a parameter in Java and fire some methods from that class? void main() { callClass(that.class) } void callClass(???? classObject) { classObject.somefunction // or new classObject() //something…
user562350
170
votes
22 answers

Can we pass parameters to a view in SQL?

Can we pass a parameter to a view in Microsoft SQL Server? I tried to create view in the following way, but it doesn't work: create or replace view v_emp(eno number) as select * from emp where emp_id=&eno;
arunachalam
  • 1,889
  • 3
  • 13
  • 6