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.
19575 questions
228
votes
34 answers

How many parameters are too many?

Routines can have parameters, that's no news. You can define as many parameters as you may need, but too many of them will make your routine difficult to understand and maintain. Of course, you could use a structured variable as a workaround:…
Auron
  • 11,904
  • 14
  • 42
  • 53
213
votes
14 answers

Ruby: How to turn a hash into HTTP parameters?

That is pretty easy with a plain hash like {:a => "a", :b => "b"} which would translate into "a=a&b=b" But what do you do with something more complex like {:a => "a", :b => ["c", "d", "e"]} which should translate into…
Julien Genestoux
  • 26,486
  • 19
  • 63
  • 91
213
votes
7 answers

HTTP Request in Swift with POST method

I'm trying to run a HTTP Request in Swift, to POST 2 parameters to a URL. Example: Link: www.thisismylink.com/postName.php Params: id = 13 name = Jack What is the simplest way to do that? I don't even want to read the response. I just want to send…
angeant
  • 2,565
  • 3
  • 15
  • 9
210
votes
10 answers

Reflection: How to Invoke Method with parameters

I am trying to invoke a method via reflection with parameters and I get: object does not match target type If I invoke a method without parameters, it works fine. Based on the following code if I call the method Test("TestNoParameters"), it works…
Ioannis
  • 2,655
  • 4
  • 22
  • 19
210
votes
10 answers

Passing Parameters JavaFX FXML

How can I pass parameters to a secondary window in javafx? Is there a way to communicate with the corresponding controller? For example: The user chooses a customer from a TableView and a new window is opened, showing the customer's info. Stage…
Alvaro
  • 10,389
  • 7
  • 36
  • 54
199
votes
9 answers

In Swift how to call method with parameters on GCD main thread?

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for this task, I need to do some computation that adds a…
almel
  • 5,614
  • 10
  • 36
  • 52
197
votes
5 answers

How to use R's ellipsis feature when writing your own function?

The R language has a nifty feature for defining functions that can take a variable number of arguments. For example, the function data.frame takes any number of arguments, and each argument becomes the data for a column in the resulting data table.…
Ryan C. Thompson
  • 37,328
  • 27
  • 87
  • 147
192
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
  • 17,401
  • 18
  • 68
  • 77
189
votes
6 answers

What is the difference between named and positional parameters in Dart?

Dart supports both named optional parameters and positional optional parameters. What are the differences between the two? Also, how can you tell if an optional parameter was actually specified?
Seth Ladd
  • 77,313
  • 56
  • 165
  • 258
186
votes
10 answers

What is the use of "ref" for reference-type variables in C#?

I understand that if I pass a value-type (int, struct, etc.) as a parameter (without the ref keyword), a copy of that variable is passed to the method, but if I use the ref keyword a reference to that variable is passed, not a new one. But with…
Andreas Grech
  • 98,643
  • 98
  • 284
  • 354
185
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
  • 25,661
  • 50
  • 173
  • 276
183
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
  • 78,414
  • 98
  • 279
  • 415
182
votes
3 answers

What does the slash mean in help() output?

What does the / mean in Python 3.4's help output for range before the closing parenthesis? >>> help(range) Help on class range in module builtins: class range(object) | range(stop) -> range object | range(start, stop[, step]) -> range object |…
Joschua
  • 4,656
  • 4
  • 27
  • 42
182
votes
8 answers

Append values to query string

I have set of URL's similar to the ones below in a list http://somesite.com/backup/lol.php?id=1&server=4&location=us http://somesite.com/news.php?article=1&lang=en I have managed to get the query strings using the following code: myurl =…
DriverBoy
  • 2,647
  • 3
  • 16
  • 21
178
votes
10 answers

PHP check whether property exists in object or class

I understand PHP does not have a pure object variable, but I want to check whether a property is in the given object or class. $ob = (object) array('a' => 1, 'b' => 12); or $ob = new stdClass; $ob->a = 1; $ob->b = 2; In JS, I can write this to…
Micah
  • 3,531
  • 7
  • 24
  • 32