parameter-passing

Why is the value of “switch” type parameter passed to a string parameter?

对着背影说爱祢 提交于 2019-12-01 18:57:22
问题 The test code ( test.ps1 ): Param( [string]$content = $null, [switch]$flag = $false ) Write-Host $content Output: PS C:\Users\powershell> .\test.ps1 PS C:\Users\powershell> .\test.ps1 -flag $true True PS C:\Users\powershell> .\test.ps1 -flag $false False PS C:\Users\powershell> .\test.ps1 -flag $true -content "lalala" lalala No matter I set $content to $null , or "" , or without any default value, the output is the same. So why does $content take the value from $flag ? 回答1: @PetSerAl already

how do I increment an integer variable I passed into a function in Scala?

别说谁变了你拦得住时间么 提交于 2019-12-01 18:14:39
I declared a variable outside the function like this: var s: Int = 0 passed it such as this: def function(s: Int): Boolean={ s += 1 return true } but the error lines wont go away under the "s +=" for the life of me. I tried everything. I am new to Scala btw. First of all, I will repeat my words of caution: solution below is both obscure and inefficient , if it possible try to stick with val ues. implicit class MutableInt(var value: Int) { def inc() = { value+=1 } } def function(s: MutableInt): Boolean={ s.inc() // parentheses here to denote that method has side effects return true } And here

Symfony: pass parameter between actions (with a redirect)

流过昼夜 提交于 2019-12-01 18:06:35
I am redirecting from one action (executeProcess) to another (executeIndex). I want to be able to pass a parameter/variable along, without using GET (e.g. $this->redirect('index', array('example'=>'true')) ) Is there a way I can directly pass parameters without having it directly displayed in the URL? (e.g. POST). thanks. Why dont you use sessions to store values before redirecting, and then getting them on the other action after you redirected? like: class ActionClass1 extendes sfActions { public function executeAction1(sfWebRequest $request) { [..]//Do Some stuff $this->getUser()-

In TCL,can we pass parameters in this way?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 17:27:16
问题 I have a question about passing parameters in Tcl regarding to the following code: set name "Ronaldo" proc GET_PLAYER_INFO {player_id {player_name "$name"}} { global name puts $player_name } regarding to the code above, we have a global variable "name", and in the parameter list of proc GET_PLAYER_INFO, the default value of parameter player_name is set to "$name"? if the value of name is "ronaldo", it is already double quotation,do we need to put double quotation in the parameters list like

Jenkins: Sharing variables in MultiJob

可紊 提交于 2019-12-01 17:10:25
I'm using Jenkins for testing/build purposes, so I created a MultiJob project with this configuration: Test Job Build Job Install Job The MultiJob is launched from the Master Jenkins, but other jobs are launched from other Nodes. The Build Job executes a shell script which creates the BUILD_ID. Now, I want the BUILD_ID to be passed as parameter to the Install Job. How can I do that? My only choice is to use a property file? Thanks a lot To use the suggestion i am going to describe, you will need Parameterized Trigger plugin. One way to pass custom parameter to a downstream job is by storing

Python. Parameters and returned values

雨燕双飞 提交于 2019-12-01 16:42:07
Being relatively new to Python in this question I may use some incorrect terminology and will display misunderstanding - which I why I am here. I am studying Python functions and am trying to ensure I understand how variables are passed and returned. I have written this trivial function to sort items in a list def func_sort_list(NN): for w in NN: print (w, type(w)) NN.sort() print (NN) return (w) I have assigned values to a list unsort_letters=['q','w','e','r','t','y'] Then I envoke the function func_sort_list(unsort_letters) and get the result q <class 'str'> w <class 'str'> e <class 'str'> r

Golang return values of function as input arguments to another

廉价感情. 提交于 2019-12-01 15:49:00
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 enough arguments in call to doSomething() Is there a way to do this or should I just give up and assign

ggplot aes_string with interaction

六眼飞鱼酱① 提交于 2019-12-01 15:03:26
问题 Using aes_string makes it easy to construct functions to take parameters to plot: p <- ggplot(mtcars, aes_string(x="mpg", y="wt", group=interaction("cyl","gear"))) + geom_point() Now to write the the function make_plot <- function(x,y, interact) { p <- ggplot(mtcars, aes_string(x=x, y=y, group=interact)) + geom_point() } and to call the function make_plot("mpg","wt",c("cyl","gear")) But here the interaction is not used, i.e., it is not interpreted. I don't want to use separate variables for

How to use the Postgres any-clause with JPA/Hibernate native queries (array parameters)

廉价感情. 提交于 2019-12-01 14:43:38
So we've got a whole lot of Postgres SQL queries stored in files and used from PHP. The task is to replace PHP with Java. We want to reuse as much of the queries "as is" to keep the migration path short. I can't get the Array parameters to work. Here's a query example: update user_devices set some_date = now() where some_id in ( select distinct some_id from user_devices where user_id = any(:userIDs) and device_id = any(:deviceIDs) and exists (select 1 from users where user_id = any(:userIDs) and customer_id = :customerID) ); Note the "any" clauses, which cause the problem, because they expect

passing variable values from c# to javascript

时光毁灭记忆、已成空白 提交于 2019-12-01 14:13:54
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 Jscript). However, my intention is to write a different object depending on my server-side code. When I