named-parameters

JPA lower() function on parameter

喜你入骨 提交于 2020-01-16 11:04:12
问题 I have updated project from spring 3.2 to 4.1 and hibernate 4.2 to 4.3.7 and got interesting problem. I have query: function parameter: String email; getQuery(getSelect() + "where lower(o.email) = lower(:email)").setParameter("email", email); now, on getting result I got org.postgresql.util.PSQLException: ERROR: function lower(bytea) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. but if I call getQuery(getSelect() +

Yii2: How do you use named parameters in console commands?

青春壹個敷衍的年華 提交于 2020-01-16 06:14:31
问题 How can I write the console command yii controller/action --param1=something --param2=anything and retrieve those named parameters in the action? 回答1: I found out that the documentation does say how to, but instead of calling it "named parameters" as I expected it to, it is called options: http://www.yiiframework.com/doc-2.0/guide-tutorial-console.html#create-command The docs is not quite complete though. So here is an example: You add the parameters as properties to the controller: class

Is there any tools to help me refactor a method call from using position-based to name-based parameters

混江龙づ霸主 提交于 2020-01-14 07:55:08
问题 I wish to transform code like: var p = new Person("Ian", "Smith", 40, 16) To: var p = new Person(surname: "Ian", givenName:"Smith", weight:40, age:16) As a first step in making the code more readable, I am willing to use a 3rd party refactoring tool if need be. (Please do not tell me to use parameter objects and factor methods etc, these may come later once I can at least read the code!) 回答1: Refactor v2001 vol 1.3 claims to be able to do it. ReSharper has it in it's issues database, but have

How do you curry the 2nd (or 3rd, 4th, …) parameter in F# or any functional language?

房东的猫 提交于 2020-01-12 13:47:36
问题 I'm just starting up with F# and see how you can use currying to pre-load the 1st parameter to a function. But how would one do it with the 2nd, 3rd, or whatever other parameter? Would named parameters to make this easier? Are there any other functional languages that have named parameters or some other way to make currying indifferent to parameter-order? 回答1: Typically you just use a lambda: fun x y z -> f x y 42 is a function like 'f' but with the third parameter bound to 42. You can also

Optional named arguments in Mathematica

匆匆过客 提交于 2020-01-12 01:14:34
问题 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 with positional arguments: foo[a_:1, b_:2, c_:3] := bar[a,b,c] Here is sample input and output for the named-arguments version of foo : foo[] --> bar[1,2,3] foo[b->7] --> bar[1,7,3] foo[a->6, b->7, c->8] --> bar[6,7,8] It should of course also

OleDB Parameters

戏子无情 提交于 2020-01-11 11:51:31
问题 I have this access db that I have a ddl for the state name and a ddl for the year. I have a gridview that I'd like to pass the value of the state drop down list into where clause. Obviously if I could use sql with the named parameters I would but this is what I'm stuck with and not sure exactly how to format it correctly. the drop down list is name ddlStates. In the parameters I've tried mycommand.Parameters.Add("@ddlStates") here is the data set public DataSet GetData() { DataSet ds; using

JavaScript function with optional parameters [duplicate]

不打扰是莪最后的温柔 提交于 2020-01-10 14:58:53
问题 This question already has answers here : How to overload functions in javascript? (13 answers) Closed 4 years ago . I'm new to JavaScript coming from Python background. In Python parameters can be passed as key and value as such: def printinfo( name, age = 35 ): print "Name: ", name print "Age ", age return; Then the function could be called as such: printinfo( age=50, name="miki" ) printinfo( name="miki" ) Can such parameters be passing in JavaScript functions? I want to be able to pass one

Can I use Named and Optional Arguments in ironpython

て烟熏妆下的殇ゞ 提交于 2020-01-04 03:24:07
问题 I hope to load .net dll in ironpython. But one of static functions in .net dll, has some Named and Optional Arguments. like, Draw(weight:w,height:h, Area=1) Only can I use full arguments? 回答1: Named and optional parameters are fully supported. .NET has had these for a long time for VB.NET support and so IronPython has supported that same way to do them since the beginning. The new C# syntax maps to the same underlying metadata as the old VB support. For calling you use f(x = 42) which is

Better Way To Use C++ Named Parameter Idiom?

随声附和 提交于 2020-01-01 04:45:08
问题 I've been developing a GUI library for Windows (as a personal side project, no aspirations of usefulness). For my main window class, I've set up a hierarchy of option classes (using the Named Parameter Idiom), because some options are shared and others are specific to particular types of windows (like dialogs). The way the Named Parameter Idiom works, the functions of the parameter class have to return the object they're called on. The problem is that, in the hierarchy, each one has to be a

Named Parameters in Ruby Structs

南笙酒味 提交于 2019-12-30 01:37:07
问题 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: Movie = Struct.new :title, :length, :rating m = Movie.new :title => 'Some Movie', :rating => 'R' This doesn't work. So I came up with the following: class MyStruct < Struct # Override the initialize to handle hashes of named parameters def