params

Variable parameters in C# Lambda

落爺英雄遲暮 提交于 2020-01-10 17:48:15
问题 Is it possible to have a C# lambda/delegate that can take a variable number of parameters that can be invoked with a Dynamic-invoke? All my attempts to use the 'params' keyword in this context have failed. UPDATE WITH WORKING CODE FROM ANSWER: delegate void Foo(params string[] strings); static void Main(string[] args) { Foo x = strings => { foreach(string s in strings) Console.WriteLine(s); }; //Added to make it clear how this eventually is used :) Delegate d = x; d.DynamicInvoke(new[]{new

Variable parameters in C# Lambda

给你一囗甜甜゛ 提交于 2020-01-10 17:48:05
问题 Is it possible to have a C# lambda/delegate that can take a variable number of parameters that can be invoked with a Dynamic-invoke? All my attempts to use the 'params' keyword in this context have failed. UPDATE WITH WORKING CODE FROM ANSWER: delegate void Foo(params string[] strings); static void Main(string[] args) { Foo x = strings => { foreach(string s in strings) Console.WriteLine(s); }; //Added to make it clear how this eventually is used :) Delegate d = x; d.DynamicInvoke(new[]{new

Can't Insert Data into Database using PDO

孤街浪徒 提交于 2020-01-06 15:29:09
问题 After sanitizing and validation, which works fine. I tried inserting data into my database but it keeps saying error: "Sorry, we were not able to sign you up... Refill the form properly" $qry = "INSERT INTO users (email, firstName, surname, userName, password, userDOB) values (?, ?, ?, ?, ?, ?)"; $q = $conn->prepare($qry) or die("ERROR: " . implode(":", $conn->errorInfo())); $q->bindParam(1, $email); $q->bindParam(2, $name); $q->bindParam(3, $surname); $q->bindParam(4, $username); $q-

Ignore uppercase, downcase and accent in search

我的未来我决定 提交于 2020-01-05 05:25:15
问题 I have a search system with filter here. This system work like a charm but I have some problem with downcase / uppercase and accent. For example if I search "marée" I have result but if I search "MAREE" or "Marée" or "maree". I don't have result. I want to fix that. How I can fix this ? Thank you. my controller def resultnohome if params[:query].blank? redirect_to action: :index and return else @campings = Camping.searchi(params[:query], params[:handicap], params[:animaux], params[:television

print currently evaluated params during scipy minimization

强颜欢笑 提交于 2020-01-02 18:05:25
问题 I am trying to minimize a function in Python using scipy.optimize.minimize , to determine four distinct parameters. I would like to print the currently evaluated params at each step of the optimisation algorithm, so I can use them to make my initial guess better. How can I do this? 回答1: Use the callback keyword argument. scipy.optimize.minimize can take a keyword argument callback . This should be a function that accepts, as input, the current vector of parameters. This function is called

Is it possible to add a value to a submit button that gets passed in the params?

我的未来我决定 提交于 2020-01-02 03:46:08
问题 I'm trying to add a "preview" button/page to my app. Is there a way to add a different value to both my "post" and "preview" submit buttons that get passed in the params hash so that I can check which one was pressed in the controller and render the view accordingly? Is this the best way to do this? 回答1: The keys of the params hash are just the name value of an element. If you had two buttons named "submit", one with value="post" and value="preview" , then you could do something like: if

Sinatra and question mark

依然范特西╮ 提交于 2019-12-29 07:32:09
问题 I need to make some methods with Sinatra that should look like: http//:localhost:1234/add?string_to_add But when I declare it like this: get "/add?:string_to_add" do ... end it doesn't see the string_to_add param. How should I declare my method and use this parameter to make things work? 回答1: In a URL, a question mark separates the path part from the query part. The query part normally consists of name/value pairs, and is often constructed by a web browser to match the data a user has entered

how to save array to database in rails

本秂侑毒 提交于 2019-12-28 14:05:08
问题 if i have params like this : params["scholarship"] = {"name"=>"test", "state_ids"=>["1", "2", "3", "4"]} and when i create object to database field state_id not save to database? how to save to database with format : #<Scholarship id: 1, name: "test", state_id: "["1", "2", "3", "4"]"> how do that? thanks before 回答1: ActiveRecord::Base.serialize. For example: class User < ActiveRecord::Base serialize :scholarship end user = User.create(:scholarship=> { "name" => "test", "state_ids" => ["1", "2

C# params object[] strange behavior

拥有回忆 提交于 2019-12-28 03:04:53
问题 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

Perl::Dancer how to include a file path as a parameter in the URI

社会主义新天地 提交于 2019-12-24 16:01:58
问题 I'm new to the Dancer framework and web apps in general. I have a Dancer project in which I have a route that accepts multiple parameters. So far, no sweat. However, if one of the parameters has a file path as its value then the route is not found. I have tried encoding the parameter string as follows to eliminate the forward slashes: $paramString =~ s/\//%2F/g; and this does encode the slashes as expected (I print it out in the log to make sure). However, after the parameter string is