Named parameters enable you to specify an argument for a particular parameter by associating the argument with the parameter's name rather than with the parameter's position in the parameter list.
Questions tagged [named-parameters]
371 questions
6
votes
2 answers
Python Named Argument is Keyword?
So an optional parameter expected in the web POST request of an API I'm using is actually a reserved word in python too. So how do I name the param in my method call:
example.webrequest(x=1,y=1,z=1,from=1)
this fails with a syntax error due to…

citronic
- 9,868
- 14
- 51
- 74
6
votes
2 answers
compiler warning on (ambiguous) method resolution with named parameters
One question regarding whether the following code should yield a compiler warning or not (it doesn't). It declares two methods of the same name/return type, one has an additional named/optional parameter with default value.
NOTE: technically the…

FireSnake
- 2,983
- 2
- 16
- 9
6
votes
4 answers
Parameter names of a function using a functional language such as F#
I have read a book called Clean code. One of the strongest messages that I took from the book is that the code must be readable. I do not understand why functional languages such as F# do not include function parameter names into the intellisense or…

Oldrich Svec
- 4,191
- 2
- 28
- 54
6
votes
2 answers
Should these arguments be added or removed?
When Resharper argues with itself, how does one know which persona to give more credence?
I think I have found some code that does confuse Resharper (this is apparently a very unusual case - after using it for a day, I think Resharper is the bee's…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
5
votes
2 answers
Kotlin default parameter only work at the end
I want some of my function parameter to be optional, so I used default parameter as follow :
fun defaultparameter(param1: String = "", param2: String = "", param3: Int = 0)
this work I can do this…

XCarb
- 735
- 10
- 31
5
votes
1 answer
Use variable name semantically in Java
I'm currently trying to set some parameters from an external system. I have a request with named parameters, and in order to properly set the variables, I'm using annotated method arguments on my service calls. A simplified example might be
public…

corsiKa
- 81,495
- 25
- 153
- 204
5
votes
2 answers
How does Scala know what method to invoke ( named parameters )
class Algo {
def a( a : String = "Hola ", b : String = "adios" ) {
print( a )
print( b )
}
def a() {
print ("Uh?")
}
}
object Algo {
def main( args : Array[String] ) {
new Algo().a()
…

OscarRyz
- 196,001
- 113
- 385
- 569
5
votes
1 answer
fetch size for NamedParameterJdbctemplate?
I am working on a problem which involves me to write a query to fetch few thousands of records from the database. The query which I would be using will include 2 IN clauses in the WHERE condition.
As per my knowledge which might be limited, please…

user641887
- 1,506
- 3
- 32
- 50
5
votes
2 answers
sqlite / python - named parameters without enclosing quotes?
When using prepared statements with named parameters in SQLite (specifically with the python sqlite3 module http://docs.python.org/library/sqlite3.html ) is there anyway to include string values without getting quotes put around them ?
I've got this…

glaucon
- 8,112
- 9
- 41
- 63
5
votes
3 answers
How to use named parameters in Python methods that are defaulting to a class level value?
Usage scenario:
# case #1 - for classes
a = MyClass() # default logger is None
a = MyClass(logger="a") # set the default logger to be "a"
a.test(logger="b") # this means that logger will be "b" only inside this method
a.test(logger=None) # this…

sorin
- 161,544
- 178
- 535
- 806
5
votes
2 answers
Optional Specification of some C# Optional Parameters
Suppose you have a method with the following signature:
public void SomeMethod(bool foo = false, bool bar = true) { /* ... */ }
When calling this method, is there a way to specify a value for bar and not foo? It would look something…

Anton
- 4,554
- 2
- 37
- 60
5
votes
1 answer
ZF2 Sql using named parameters
Is it possible to use named parameters in a Select, Update or Delete query object in Zend Framework 2? e.g.
$myValue = 'FooBar';
$sql = new Zend\Db\Sql\Sql($adapter);
$select = $sql->select('my_table')
->where('my_column =…

gawpertron
- 1,867
- 3
- 21
- 37
5
votes
4 answers
How to guard against function arguments being passed in the wrong order?
Say I have a C++ function that looks like this:
double myfunction(double a, double b) {
// do something
}
Which I then call like this:
double a = 1.0;
double b = 2.0;
double good_r = myfunction(a, b);
double bad_r = myfunction(b, a); //…

user2664470
- 781
- 1
- 7
- 17
5
votes
1 answer
Named parameters with Python C API?
How can I simulate the following Python function using the Python C API?
def foo(bar, baz="something or other"):
print bar, baz
(i.e., so that it is possible to call it via:
>>> foo("hello")
hello something or other
>>> foo("hello",…

Michael
- 11,612
- 10
- 41
- 43
5
votes
1 answer
Groovy named parameters cause parameter assignments to switch--any way around this?
Groovy will collect all the named parameters into a map and pass it into a method as the first parameter. This seems neat, but after trying to make it work it seems really unusable.
So the issue is a method like this:
def method(paramMap,…

Bill K
- 62,186
- 18
- 105
- 157