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
2638
votes
29 answers

Set a default parameter value for a JavaScript function

I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn't defined (and ignored if the value is passed). In Ruby you can do it like this: def read_file(file, delete_after = false) #…
Tilendor
  • 48,165
  • 17
  • 52
  • 58
2098
votes
28 answers

Does Java support default parameter values?

I came across some Java code that had the following structure: public MyParameterizedFunction(String param1, int param2) { this(param1, param2, false); } public MyParameterizedFunction(String param1, int param2, boolean param3) { //use all…
gnavi
  • 25,122
  • 7
  • 21
  • 11
1716
votes
10 answers

How are parameters sent in an HTTP POST request?

In an HTTP GET request, parameters are sent as a query string: http://example.com/page?parameter=value&also=another In an HTTP POST request, the parameters are not sent along with the URI. Where are the values? In the request header? In the request…
Camilo Martin
  • 37,236
  • 20
  • 111
  • 154
1447
votes
7 answers

Passing parameters to a Bash function

I am trying to search how to pass parameters in a Bash function, but what comes up is always how to pass parameter from the command line. I would like to pass parameters within my script. I tried: myBackupFunction("..", "...", "xx") function…
stivlo
  • 83,644
  • 31
  • 142
  • 199
1421
votes
5 answers

What are the -Xms and -Xmx parameters when starting JVM?

Please explain the use of the Xms and Xmx parameters in JVMs. What are the default values for them?
Pankaj
  • 14,638
  • 3
  • 17
  • 23
1132
votes
41 answers

Parameterize an SQL IN clause

How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? SELECT * FROM Tags WHERE Name IN ('ruby','rails','scruffy','rubyonrails') ORDER BY Count DESC In this query, the number of arguments could be…
Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
1020
votes
38 answers

What's the difference between an argument and a parameter?

When verbally talking about methods, I'm never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms? I'm a C# programmer, but I…
rohancragg
  • 5,030
  • 5
  • 36
  • 47
1007
votes
30 answers

How can I pass a parameter to a setTimeout() callback?

I have some JavaScript code that looks like: function statechangedPostQuestion() { //alert("statechangedPostQuestion"); if (xmlhttp.readyState==4) { var topicId = xmlhttp.responseText; setTimeout("postinsql(topicId)",4000); …
Zeeshan Rang
  • 19,375
  • 28
  • 72
  • 100
854
votes
16 answers

Pass a JavaScript function as parameter

How do I pass a function as a parameter without the function executing in the "parent" function or using eval()? (Since I've read that it's insecure.) I have this: addContact(entityId, refreshContactList()); It works, but the problem is that…
imperium2335
  • 23,402
  • 38
  • 111
  • 190
807
votes
10 answers

How do you pass a function as a parameter in C?

I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?
andrewrk
  • 30,272
  • 27
  • 92
  • 113
782
votes
34 answers

How to get URL parameter using jQuery or plain JavaScript?

I have seen lots of jQuery examples where parameter size and name are unknown. My URL is only going to ever have 1 string: http://example.com?sent=yes I just want to detect: Does sent exist? Is it equal to "yes"?
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
722
votes
1 answer

"Parameter" vs "Argument"

I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other. Can you please tell me?
dummy
690
votes
23 answers

Decorators with parameters?

I have a problem with the transfer of the variable insurance_mode by the decorator. I would do it by the following decorator statement: @execute_complete_reservation(True) def test_booking_gta_object(self): self.test_select_gta_object() but…
falek.marcin
  • 9,679
  • 9
  • 28
  • 33
679
votes
13 answers

What does int argc, char *argv[] mean?

In many C++ IDE's and compilers, when it generates the main function for you, it looks like this: int main(int argc, char *argv[]) When I code C++ without an IDE, just with a command line compiler, I type: int main() without any parameters. What…
Greg Treleaven
  • 8,124
  • 7
  • 30
  • 30
493
votes
37 answers

Adding a parameter to the URL with JavaScript

In a web application that makes use of AJAX calls, I need to submit a request but add a parameter to the end of the URL, for example: Original URL: http://server/myapp.php?id=10 Resulting URL: http://server/myapp.php?id=10&enabled=true Looking…
Lessan Vaezi
  • 6,927
  • 3
  • 25
  • 15
1
2 3
99 100