Home

arg2

Arg2 is a conventional placeholder name used in programming to denote the second argument passed to a function or command. It is not a defined language construct, but appears in examples, tutorials, and documentation to illustrate how a program handles multiple inputs.

In function signatures, arg1 and arg2 are common dummy parameter names. Examples in common languages show this

In command-line contexts, arg2 often refers to the second positional parameter provided by a user. For Bash

Naming and best practices: Because arg1 and arg2 are non-descriptive, many style guides discourage using such

See also: parameter naming, positional argument, command-line argument, argument parsing.

usage:
In
C,
int
add(int
arg1,
int
arg2)
{
return
arg1
+
arg2;
}
In
Python,
def
add(arg1,
arg2):
return
arg1
+
arg2;
In
JavaScript,
function
add(arg1,
arg2)
{
return
arg1
+
arg2;
}.
These
examples
are
for
illustration
and
do
not
imply
special
meaning
in
the
language.
scripts,
the
second
argument
is
accessed
as
$2;
in
Python,
the
second
command-line
argument
is
sys.argv[2]
(with
sys.argv[0]
being
the
script
name).
The
exact
indexing
depends
on
the
language
and
the
convention
used
to
represent
the
program’s
arguments.
placeholders
in
real
APIs
or
public
code.
Descriptive
names,
such
as
width
and
height,
filename,
threshold,
or
other
semantically
meaningful
identifiers,
improve
readability
and
maintainability.
When
possible,
rely
on
explicit
parameter
names
or
structured
arguments
parsed
by
a
library
to
reduce
ambiguity.