params

Rails: Plus sign in GET-Request replaced by space

时光总嘲笑我的痴心妄想 提交于 2019-11-27 15:48:43
问题 In Rails 3 (Ruby 1.9.2) I send an request Started GET "/controller/action?path=/41_+" But the parameter list looks like this: {"path"=>"/41_ ", "controller"=>"controller", "action"=>"action"} Whats going wrong here? The - , * or . sign works fine, its just the + which will be replaced by a space. 回答1: That's normal URL encoding, the plus sign is a shorthand for a space: Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be

C# params object[] strange behavior

你。 提交于 2019-11-27 09:13:06
Considering this code namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] strings = new string[] { "Test1", "Test2", "Test3" }; int[] ints = new int[] { 1, 2, 3, 4 }; Test(strings); Test(ints); } public static void Test(params object[] objects) { } } } And this page https://msdn.microsoft.com/fr-ca/library/w5zay9db.aspx I would expect (params object[] objects) to be an array of one element with a string[] as the first element, but when I debug, I see that (params object[] objects) is { "Test1", "Test2", "Test3" }. However, with an int[], I get an object[]

Is there a way to distingish myFunc(1, 2, 3) from myFunc(new int[] { 1, 2, 3 })?

家住魔仙堡 提交于 2019-11-27 06:54:22
问题 A question to all of you C# wizards. I have a method, call it myFunc, and it takes variable length/type argument lists. The argument signature of myFunc itself is myFunc(params object[] args) and I use reflection on the lists (think of this a bit like printf, for example). I want to treat myFunc(1, 2, 3) differently from myFunc(new int[] { 1, 2, 3 }) . That is, within the body of myFunc, I would like to enumerate the types of my arguments, and would like to end up with { int, int, int} rather

Android set height and width of Custom view programmatically

微笑、不失礼 提交于 2019-11-27 06:15:06
I have created a custom view named Graphview . Here is the structure for the GraphView class. public class GraphView extends View { public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean type) { super(context); ........ } .................. ................. } I have added the view in a tablerow using addview() . It is working fine. Now I want to set height and width for the GraphView . How to do that? The easy way is to set the size programatically like that : graphView.setLayoutParams(new LayoutParams(width, height)); This is fine if

How to get a Date from date_select or select_date in Rails?

删除回忆录丶 提交于 2019-11-27 03:57:46
Using select_date gives me back a params[:my_date] with year , month and day attributes. How do get a Date object easily? I'm hoping for something like params[:my_date].to_date . I'm happy to use date_select instead as well. Using date_select gives you 3 separate key/value pairs for the day, month, and year respectively. So you can pass them into Date.new as parameters to create a new Date object. An example date_select returned params for an Event model: "event"=> {"name"=>"Birthday", "date(1i)"=>"2012", "date(2i)"=>"11", "date(3i)"=>"28"}, Then to create the new Date object: event = params[

how can I hide params I transmit to a method (like form_for seems to do)?

那年仲夏 提交于 2019-11-27 03:42:02
问题 I've been searching for hours now and haven't found anything that helps. What I want to do: I need to call the check_login -Method (as below), which needs parameters. redirect_to check_login_users_url( :user => {:name => input[1], :password => input [2] }, :stylesheet => 'scaffold', :method => :get) The point is that these params are sent in the method-call as in the "Redirected to"-line below. Processing ApplicationController#execute(for 127.0.0.1 at 2009-12-19 00:28:40) [POST] Parameters: {

Does C# support a variable number of arguments, and how?

眉间皱痕 提交于 2019-11-27 01:47:45
Does C# support a variable number of arguments? If yes, How does C# support variable no of arguments? What are the examples? How are variable arguments useful? EDIT 1 : What are the restrictions on it? EDIT 2 : The Question is not about Optional param But Variable Param Yes. The classic example wourld be the params object[] args : //Allows to pass in any number and types of parameters public static void Program(params object[] args) A typical usecase would be passing parameters in a command line environment to a program, where you pass them in as strings. The program has then to validate and

Java “params” in method signature?

做~自己de王妃 提交于 2019-11-27 00:45:26
In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a params so that the method parameter looks like an array but allows everyone using the method to pass as many parameters of that type as the caller wants. I'm fairly sure Java supports similar behaviour, but I cant find out how to do it. David Grant In Java it's called varargs , and the syntax looks like a regular parameter, but with an ellipsis ("...") after the type: public void foo(Object... bar) { for (Object baz : bar) { System.out.println(baz.toString()); }

Load AS2 SWF Into AS3 SWF and pass vars in URL

夙愿已清 提交于 2019-11-26 23:31:29
问题 I've got an AS3 SWF that I'm going to be loading other SWFs into. These child SWFs all take a single parameter on the URL. I can't seem to get it working when loading an AS2 child, and it needs to be able to handle both. so I have var request:URLRequest = new URLRequest(); var loader:URLLoader = new URLLoader(); request.url = "http://domain/as2.swf?param=foo"; loader.load(request); // etc on to the eventListeners, addChild, etc When the as2 SWF gets loaded, it can't see the parameter I've

How does C# choose with ambiguity and params

拜拜、爱过 提交于 2019-11-26 22:34:56
Say I have the following methods: public static void MyCoolMethod(params object[] allObjects) { } public static void MyCoolMethod(object oneAlone, params object[] restOfTheObjects) { } If I do this: MyCoolMethod("Hi", "test"); which one gets called and why? It's easy to test - the second method gets called. As to why - the C# language specification has some pretty detailed rules about how ambiguous function declarations get resolved. There are lots of questions on SO surrounding interfaces, inheritance and overloads with some specific examples of why different overloads get called, but to