Ways to refactor named arguments with default values

I have a method with a lot of named arguments, some with default values: def myClass def initialize(a:, b:, c:, d:, e:, f:, g: nil, h: nil, i: nil) ... end end The list is a little hard to look at and comprehend. I am looking for way to make this sim

Resharper - keep the named parameters when cleaning the code

We've adopted a convention that when calling a C# function with a "non-obvious" parameter, we use a named parameter even when it's not necessary. E.g. obj.Process(save: true) rather than obj.Process(true) While it's unnecessary, it makes it a lo

Parameter named sqlite python containing a dash

I'm trying to insert a record into an sqlite database using named parameters in python (with the sqlite3 module). The values I want to insert are in a dictionary, but the dictionary keys might contain dashes, for example {'request-id': 100, 'year': '

Types of C Function Pointers with Named Parameters

On MSVC and gcc (GCC) 4.8.3 20140911 the following compiles and runs just fine: #include <stdio.h> int func(int a, int b){ return 0; } int main(void){ int (*funcPointer)(int a, int b); funcPointer = func; printf("funcPointer = %p\n", funcP

Using Named arguments and optional to distinguish constructors

Imagine a class which can, in principle, be created by specifying the value of one of two properties, both of which happen to have the same type. The following code accomplishes this by using a combination of named and optional parameters to discrimi

NamedParameterJdbcTemplate and composite key

I've written a method to retrieve a list of entries with NamedParameterJdbcTemplate: public final Map<K,V> findAll(final Collection<K> keys) { if (keys == null) { return null; } MapSqlParameterSource parameters = new MapSqlParameterSource(); p

Value classes introduce unwanted public methods

Looking at some scala-docs of my libraries, it appeared to me that there is some unwanted noise from value classes. For example: implicit class RichInt(val i: Int) extends AnyVal { def squared = i * i } This introduces an unwanted symbol i: 4.i // ar

How can I find the missing parameters in a C # function call?

When a named parameter in a C# function is missing, the compiler only prints the number of arguments that are missing instead of printing the name of each missing parameter in the function: prog.cs(10,27): error CS1501: No overload for method `create

Optional arguments with the default value in Ruby

I would like to create a function that has optional arguments with default values def my_function(a = nil, b=nil, c=500) end and call the function with the arguments I would like to specify only my_function(b=100) How do I accomplish this in Ruby 1.9

Dynamic call of a method using named parameters

We're currently using .NET 3.5 and part of our application uses dynamic invocation (using MethodBase.Invoke) I am wondering if it is possible to mix in Named Parameters (in .NET 4) with dynamic invocation, to perform something similar to: // Dictiona

How to set C # named parameters

This seems like a simple question, but for some reason I can't find the answer anywhere. Basically, I'd like to be able to implement a constructor that takes NamedParameters. By named parameters, I do not mean parameters with default values (optional

Parameters named in javascript

I find the named parameters feature in C# quite useful in some cases. calculateBMI(70, height: 175); What if I want this in javascript? What I don't want is - myFunction({ param1 : 70, param2 : 175}); function myFunction(params){ //check if params is

Pass lambda functions as named parameters in C #

Compile this simple program: class Program { static void Foo( Action bar ) { bar(); } static void Main( string[] args ) { Foo( () => Console.WriteLine( "42" ) ); } } Nothing strange there. If we make an error in the lambda function body: Foo(

Passing values ​​in methods

So let's say you have: public void TestFishsticks() { var fishes = GetFishstick(false); } private object GetFishstick(bool getBigFishes) { return FishsticksManager().GetFishsticks(getBigFishes); } vs public void TestFishsticks() { var fishes = GetFis

Parameters named in Ruby Structs

I'm pretty new to Ruby so apologies if this is an obvious question. I'd like to use named parameters when instantiating a Struct, i.e. be able to specify which items in the Struct get what values, and default the rest to nil. For example I want to do

MS Access, Named Parameters, and Column Names

I have the following query which I am executing on an Access database. The query, when run in Access returns accurate results. However when run from the code I get back all of the items in the database, even those which fall outside the date range I

Query HQL with several criteria

I am trying to write a HQL Query which selectes rows from a table based on multiple criteria. firstName,lastName the catch is that the query should be flexible to ignore any empty or null values so select t from table t where (:firstname = '' or t.fi

Has C # 2.0-3.0 named the arguments for the methods?

Is there a way to have named arguments like in perl/python for example object.method(arg1 => value1, arg2 => value2, arg3 => 0); in C# prior to C# 4.0?method named arguments are C# 4.0 feature. (You can't have method optional parameters in C# <

Optional named arguments in Mathematica

What's the best/canonical way to define a function with optional named arguments? To make it concrete, let's create a function foo with named arguments a, b, and c, which default to 1, 2, and 3, respectively. For comparison, here's a version of foo w

Normal Python Arguments Against Keyword Arguments

How are "keyword arguments" different from regular arguments? Can't all arguments be passed as name=value instead of using positional syntax?there are two related concepts, both called "keyword arguments". On the calling side, which is

Named / Optional Parameters in Delphi?

In one of the Delphi demo applications, I've stumbled upon some syntax that I didn't know the Delphi compiler accepted: // ......\Demos\DelphiWin32\VCLWin32\ActiveX\OleAuto\SrvComp\Word\ // Main.pas, line 109 Docs.Add(NewTemplate := True); // note th