Questions tagged [arguments]

An argument is a value passed to a function, procedure, or command line program. This also refers to the Array-like `arguments` object in JavaScript.

An argument is a value passed to a function, procedure, or program. It is often used interchangeably with the word "parameter", which also has more specific definitions. Usually "argument", or "actual parameter" (as opposed to "formal parameter") is the value of the parameter used within the called routine.

In other words, parameters are used in procedure definitions, and arguments are used in procedure calls.

arguments can also refer to the Array-like object in JavaScript that is available inside functions, this object can be used to access all of the function's arguments regardless of the function's signature.

11091 questions
268
votes
14 answers

How to pass arguments to a Button command in Tkinter?

Suppose I have the following Button made with Tkinter in Python: import Tkinter as Tk win = Tk.Toplevel() frame = Tk.Frame(master=win).grid(row=1, column=1) button = Tk.Button(master=frame, text='press', command=action) The method action is called…
Jack
  • 5,264
  • 7
  • 34
  • 43
266
votes
14 answers

How best to determine if an argument is not sent to the JavaScript function

I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I'm wondering if one method is better than the other or if one is just bad to use? function Test(argument1, argument2) { if…
Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
265
votes
12 answers

Is it possible to get all arguments of a function as single object inside that function?

In PHP there is func_num_args and func_get_args, is there something similar for JavaScript?
rsk82
  • 28,217
  • 50
  • 150
  • 240
261
votes
14 answers

jQuery pass more parameters into callback

Is there a way to pass more data into a callback function in jQuery? I have two functions and I want the callback to the $.post, for example, to pass in both the resulting data of the AJAX call, as well as a few custom arguments function clicked()…
atp
  • 30,132
  • 47
  • 125
  • 187
240
votes
9 answers

Default function arguments in Rust

Is it possible to create a function with a default argument? fn add(a: int = 1, b: int = 2) { a + b }
Jeroen
  • 15,257
  • 12
  • 59
  • 102
239
votes
5 answers

What is the difference between _tmain() and main() in C++?

If I run my C++ application with the following main() method everything is OK: int main(int argc, char *argv[]) { cout << "There are " << argc << " arguments:" << endl; // Loop through each argument and print its number and value for (int…
joshcomley
  • 28,099
  • 24
  • 107
  • 147
232
votes
9 answers

PHP function overloading

Coming from C++ background ;) How can I overload PHP functions? One function definition if there are any arguments, and another if there are no arguments? Is it possible in PHP? Or should I use if else to check if there are any parameters passed…
Vamsi Krishna B
  • 11,377
  • 15
  • 68
  • 94
232
votes
19 answers

How do you input command line arguments in IntelliJ IDEA?

I usually input command line arguments in Eclipse via run configuration. But I don't know how do achieve the same task in IntelliJ IDEA.
sungkwangsong
  • 5,575
  • 4
  • 26
  • 18
231
votes
6 answers

Default argument values in JavaScript functions

Possible Duplicate: How do I make a default value for a parameter to a javascript function in PHP: function func($a = 10, $b = 20){ // if func() is called with no arguments $a will be 10 and $ b will be 20 } How can you do this in…
Douglas Crockford
  • 2,325
  • 2
  • 14
  • 4
220
votes
16 answers

Using Default Arguments in a Function

I am confused about default values for PHP functions. Say I have a function like this: function foo($blah, $x = "some value", $y = "some other value") { // code here! } What if I want to use the default argument for $x and set a different…
renosis
  • 2,702
  • 2
  • 19
  • 22
219
votes
4 answers

How do I find the number of arguments passed to a Bash script?

How do I find the number of arguments passed to a Bash script? This is what I have currently: #!/bin/bash i=0 for var in "$@" do i=i+1 done Are there other (better) ways of doing this?
sabri
  • 2,219
  • 2
  • 14
  • 4
211
votes
10 answers

Multiple arguments vs. options object

When creating a JavaScript function with multiple arguments, I am always confronted with this choice: pass a list of arguments vs. pass an options object. For example I am writing a function to map a nodeList to an array: function map(nodeList,…
Christophe
  • 27,383
  • 28
  • 97
  • 140
205
votes
6 answers

Mockito match any class argument

Is there a way to match any class argument of the below sample routine? class A { public B method(Class a) {} } How can I always return a new B() regardless of which class is passed into method? The following attempt only works…
Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148
199
votes
4 answers

How to expand a list to function arguments in Python

Is there syntax that allows you to expand a list into the arguments of a function call? Example: # Trivial example function, not meant to do anything useful. def foo(x,y,z): return "%d, %d, %d" %(x,y,z) # List of values that I want to pass into…
Brian McFarland
  • 9,052
  • 6
  • 38
  • 56
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