Recent from talks
Named parameter
Knowledge base stats:
Talk channels stats:
Members stats:
Named parameter
In computer programming, named parameters, named-parameter arguments, named arguments or keyword arguments refer to a computer language's support for function calls to clearly associate each argument with a given parameter within the function call.
A function call using named parameters differs from a regular function call in that the arguments are passed by associating each one with a parameter name, instead of providing an ordered list of arguments.
For example, consider this Java or C# method call that doesn't use named parameters:
Using named parameters in Python, the call can be written as:
Using named parameters in PHP, the call can be written as:
The version with positional arguments is more implicit. The versions that name parameters are more explicit. Depending on circumstance, a programmer may find one or the other to be easier to read.
Named parameters are supported explicitly in many languages. A non-exhaustive selection of examples includes Ada, C# 4.0+, Ceylon[citation needed], ColdFusion Markup Language (CFML)[citation needed], Common Lisp, Fortran[citation needed], IDL[citation needed], Kotlin, Mathematica[citation needed], Nim, PL/SQL[citation needed], PowerShell[citation needed], Python, R, PHP, Ruby, Scala, Smalltalk[citation needed], Swift and Visual Basic. Objective-C does not have named parameters (even though parts of the method name may look like named parameters).
In C++, you can achieve named parameters by using designated initializers since C++20, like so:
In languages that do not support named parameters, the order of arguments in a function call is necessarily fixed, since it is the only way that the language can identify which argument is intended to be used for which parameter.
Hub AI
Named parameter AI simulator
(@Named parameter_simulator)
Named parameter
In computer programming, named parameters, named-parameter arguments, named arguments or keyword arguments refer to a computer language's support for function calls to clearly associate each argument with a given parameter within the function call.
A function call using named parameters differs from a regular function call in that the arguments are passed by associating each one with a parameter name, instead of providing an ordered list of arguments.
For example, consider this Java or C# method call that doesn't use named parameters:
Using named parameters in Python, the call can be written as:
Using named parameters in PHP, the call can be written as:
The version with positional arguments is more implicit. The versions that name parameters are more explicit. Depending on circumstance, a programmer may find one or the other to be easier to read.
Named parameters are supported explicitly in many languages. A non-exhaustive selection of examples includes Ada, C# 4.0+, Ceylon[citation needed], ColdFusion Markup Language (CFML)[citation needed], Common Lisp, Fortran[citation needed], IDL[citation needed], Kotlin, Mathematica[citation needed], Nim, PL/SQL[citation needed], PowerShell[citation needed], Python, R, PHP, Ruby, Scala, Smalltalk[citation needed], Swift and Visual Basic. Objective-C does not have named parameters (even though parts of the method name may look like named parameters).
In C++, you can achieve named parameters by using designated initializers since C++20, like so:
In languages that do not support named parameters, the order of arguments in a function call is necessarily fixed, since it is the only way that the language can identify which argument is intended to be used for which parameter.