parameter-passing

Golang return values of function as input arguments to another

不问归期 提交于 2019-12-04 03:11:38
问题 If I have func returnIntAndString() (i int, s string) {...} And I have: func doSomething(i int, s string) {...} Then I can do the following successfully: doSomething(returnIntAndString()) However, let's say I want to add another argument to doSomething like: func doSomething(msg string, i int, s string) {...} Go complains when compiling if I call it like: doSomething("message", returnIntAndString()) With: main.go:45: multiple-value returnIntAndString() in single-value context main.go:45: not

Allow either named arguments or positional arguments in Javascript

流过昼夜 提交于 2019-12-04 03:10:09
问题 How can I have a function accept either named arguments ( foo({a: 'hello', b: 'it is me'}) ) or positional arguments ( foo('hello', 'it is me') )? I understand that named arguments can be simulated by passing an object to the function: function foo(options) { options = options || {}; var a = options.a || 'peanut'; // whatever default value var b = options.b || 'butter'; // whatever default value console.log(a, b); } // ES6 allows automatic destructuring function foo({a = 'peanut', b = 'butter

Spring 3 — form with 2 buttons, sending 2 parameters to controller method

孤街浪徒 提交于 2019-12-04 03:08:46
I have a Spring 3 MVC form with 2 parameters I'm trying to send to my controller method, and I'm getting a 404 error. The twist on this problem is that the form has 2 submit buttons, and the submit button that is clicked dictates the value of one of the parameters. Here is my form. <form:form action="/approve/${bulletin.id}" method="post"> <table> <tr> <td colspan="2"><b>From:</b> <c:out value="${bulletin.name}" /></td> </tr> <tr> <td colspan="2"><b>Subject:</b> <c:out value="${bulletin.subject}" /></td> </tr> <tr> <td colspan="2"><b>Date:</b> <c:out value="${bulletin.date}" /> <br></td> </tr>

Angular2: ng-content attributes passing to child component

心已入冬 提交于 2019-12-04 02:48:24
Is something like this possible? I want to pass an "hasfocus" variable from cjc-box through ng-content attributes to the cjc-input component. app.component.html <div cjc-box><div cjc-input></div></div> cic-box.component.html <div class="cjc-box"> <div><ng-content hasfocus="focus"></ng-content></div> </div> cic-input.component.html <input class="cjc-input" type="text" focus="{{hasfocus}}" /> Is this even possible with projections in ng2? It is possible to pass variable to projected content (assuming component cjc-box declares property focus and component cjc-input declares property hasfocus ):

passing variable values from c# to javascript

北城余情 提交于 2019-12-04 02:29:53
问题 First of all, sorry for bringing a question that has been answered so many times, but I have tried most of the procedures mentioned and still can't get it working. I have an ASP.NET app (server-side), and I would like to visualize some results by using WebGL (JavaScript, client-side). I am able to create the canvas in aspx file and to draw a 3D object (a cube) by writing ALL the necessary JS code in a jscript file (As long as I know what I want to draw in advance, and writing all that in

Powershell fails to return proper exit code

故事扮演 提交于 2019-12-04 02:26:22
When executing a Powershell script (in 2.0) using the -File command line switch, and explicitly defining the input parameters in Param, the exit code is always "0" (never fails) instead of properly returning the defined or expected error code. This does not occur when using the explicit parameter definitions and the -Command switch, however for extraneous purposes, I need to keep the -File switch in my scripts. Any assistance with a workaround (that doesn't involve removing the explicit parameter definitions) would be extremely helpful. Powershell "fails to return correct exit code": exit1.ps1

Fragment (anchor #) in .NET 4 WebBrowser Control getting lost with Adobe PDF Reader and file://

烈酒焚心 提交于 2019-12-04 01:50:47
问题 I create an URI with a fragment (aka anchor #). UriBuilder ub = new UriBuilder("file://path/doc.pdf"); ub.Fragment = "chapterX"; The url is shown correctly in the debugger (ub -> file://path/doc.pdf#chapterX ). But when I assign it to a WebBrowser control, the fragment part gets lost (reason for the fragment see PDF Open parameter). this._myWebBrowser.Url = ub.Uri; // Alternative this._myWebBrowser.Navigate("file://path/doc.pdf#chapterX"); When I check this._myWebBrowser.Url it displays file:

Passing a parameter through server.execute?

妖精的绣舞 提交于 2019-12-04 00:50:07
问题 It is possible to pass a parameter through server.execute ? Fx. I have in my site.asp an IF-scenario where I need functions.asp?a=something&id=123 executed. Is this possible?! On site.asp: dim id id = 123 if b = "hi" then server.execute("functions.asp?a=something&id=" & id) else response.write("No way dude") end if On functions.asp a = request.querystring("a") id = request.querystring("id") if a = "something" and cint(id) > 100 then response.write("Yes way dude") else response.write("No way

Passing strings as arguments in dplyr verbs

妖精的绣舞 提交于 2019-12-04 00:37:35
I would like to be able to define arguments for dplyr verbs condition <- "dist > 50" and then use these strings in dplyr functions : require(ggplot2) ds <- cars ds1 <- ds %>% filter (eval(condition)) ds1 But it throws in error Error: filter condition does not evaluate to a logical vector. The code should evaluate as: ds1<- ds %>% filter(dist > 50) ds1 Resulting in : ds1 speed dist 1 14 60 2 14 80 3 15 54 4 18 56 5 18 76 6 18 84 7 19 68 8 20 52 9 20 56 10 20 64 11 22 66 12 23 54 13 24 70 14 24 92 15 24 93 16 24 120 17 25 85 Question: How to pass a string as an argument in a dplyr verb? Since

How to determine the type of a function parameter given the type of argument passed to it?

爷,独闯天下 提交于 2019-12-04 00:10:44
I need a type trait which will report the type of a functor's operator() parameter given the type of the functor and the type of an argument passed to it. Basically, I need to determine precisely what type the argument will be converted to when passing it to the functor. For simplicity, let's assume that I'm only interested in a (potentially templated, potentially overloaded) operator() with a single argument. Unfortunately, I'm limited to c++03. Can it be done? If not, how about c++11? Here's one example: #include <cassert> #include <type_traits> template<typename Functor, typename Argument>