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
119
votes
5 answers

How do I pass multiple attributes into an Angular.js attribute directive?

I have an attribute directive restricted as follows: restrict: "A" I need to pass in two attributes; a number and a function/callback, accessing them within the directive using the attrs object. If the directive was an element directive,…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
119
votes
11 answers

In Javascript/jQuery what does (e) mean?

I am new to JavaScript/jQuery and I've been learning how to make functions. A lot of functions have cropped up with (e) in brackets. Let me show you what I mean: $(this).click(function(e) { // does something }); It always appears that the…
shrewdbeans
  • 11,971
  • 23
  • 69
  • 115
118
votes
4 answers

Android: How can I pass parameters to AsyncTask's onPreExecute()?

I use an AsyncTask for loading operations that I implemented as an inner class. In onPreExecute() I show a loading dialog which I then hide again in onPostExecute(). But for some of the loading operations I know in advance that they will finish…
Steven Meliopoulos
  • 4,450
  • 4
  • 34
  • 36
116
votes
12 answers

Why not infer template parameter from constructor?

my question today is pretty simple: why can't the compiler infer template parameters from class constructors, much as it can do from function parameters? For example, why couldn't the following code be valid: template class Variable…
GRB
  • 1,515
  • 2
  • 11
  • 10
116
votes
3 answers

Java "params" in method signature?

In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a params so that the method parameter looks like an array but allows everyone using the method to pass as many…
Omar Kooheji
  • 54,530
  • 68
  • 182
  • 238
116
votes
4 answers

Difference between parameter and argument

Is there a difference between a "parameter" and an "argument", or are they simply synonyms?
Chunky Chunk
  • 16,553
  • 15
  • 84
  • 162
115
votes
21 answers

How would I skip optional arguments in a function call?

OK I totally forgot how to skip arguments in PHP. Lets say I have: function getData($name, $limit = '50', $page = '1') { ... } How would I call this function so that the middle parameter takes the default value (ie. '50')? getData('some name',…
Sebastian
114
votes
3 answers

Difference between terms: "option", "argument", and "parameter"?

What are the differences between these terms: "option", "argument", and "parameter"? In man pages these terms often seem to be used interchangeably.
what is what
  • 1,461
  • 2
  • 12
  • 16
114
votes
6 answers

Mark parameters as NOT nullable in C#/.NET?

Is there a simple attribute or data contract that I can assign to a function parameter that prevents null from being passed in C#/.NET? Ideally this would also check at compile time to make sure the literal null isn't being used anywhere for it and…
Neil C. Obremski
  • 18,696
  • 24
  • 83
  • 112
113
votes
6 answers

Escaping Double Quotes in Batch Script

How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string: @echo off call bash --verbose -c…
eplawless
  • 4,225
  • 7
  • 34
  • 35
110
votes
11 answers

'UserControl' constructor with parameters in C#

Call me crazy, but I'm the type of guy that likes constructors with parameters (if needed), as opposed to a constructor with no parameters followed by setting properties. My thought process: if the properties are required to actually construct the…
JustLooking
  • 2,405
  • 4
  • 28
  • 38
109
votes
3 answers

Can I create view with parameter in MySQL?

I have a view like this: CREATE VIEW MyView AS SELECT Column FROM Table WHERE Value = 2; I'd like to make it more generic, it means to change 2 into a variable. I tried this: CREATE VIEW MyView AS SELECT Column FROM Table WHERE Value =…
ssobczak
  • 1,795
  • 3
  • 18
  • 28
109
votes
13 answers

Http Servlet request lose params from POST body after read it once

I'm trying to access two http request parameters in a Java Servlet filter, nothing new here, but was surprised to find that the parameters have already been consumed! Because of this, they are not available in the filter chain anymore. It seems that…
amuniz
  • 3,292
  • 2
  • 20
  • 22
107
votes
6 answers

Is there a reasonable approach to "default" type parameters in C# Generics?

In C++ templates, one can specify that a certain type parameter is a default. I.e. unless explicitly specified, it will use type T. Can this be done or approximated in C#? I'm looking for something like: public class MyTemplate
el2iot2
  • 6,428
  • 7
  • 38
  • 51
106
votes
15 answers

including parameters in OPENQUERY

How can I use a parameter inside sql openquery, such as: SELECT * FROM OPENQUERY([NameOfLinkedSERVER], 'SELECT * FROM TABLENAME where field1=@someParameter') T1 INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK
gaponte69
  • 1,337
  • 3
  • 14
  • 21