parameter-passing

passing javascript method params as object literal [closed]

末鹿安然 提交于 2021-02-19 07:20:59
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . Improve this question I habitually pass parameters to functions as object literals, thus.... calling: render({ param1: 99 param2: {'a': 88, 'b': 77} }); method: render: function (p) { alert( p.param1); var data = p.param2; etc } I tend to pass parameters like this in all

PowerShell: Cannot find proper .ctor when the .ctor has only one argument of type List<T> [duplicate]

非 Y 不嫁゛ 提交于 2021-02-19 07:18:13
问题 This question already has answers here : How do I call New-Object for a constructor which takes a single array parameter? (2 answers) Closed 2 years ago . It seems that there is a bug in the O-O support in PowerShell . When instantiating an object of a class with a constructor that accepts a List< T > and this is the only parameter , PowerShell cannot find a proper constructor. Code sample: class MyClass { MyClass( #[int]$i, [System.Collections.Generic.List[string]] $theparams) { } }

PowerShell: Cannot find proper .ctor when the .ctor has only one argument of type List<T> [duplicate]

六月ゝ 毕业季﹏ 提交于 2021-02-19 07:16:47
问题 This question already has answers here : How do I call New-Object for a constructor which takes a single array parameter? (2 answers) Closed 2 years ago . It seems that there is a bug in the O-O support in PowerShell . When instantiating an object of a class with a constructor that accepts a List< T > and this is the only parameter , PowerShell cannot find a proper constructor. Code sample: class MyClass { MyClass( #[int]$i, [System.Collections.Generic.List[string]] $theparams) { } }

How substitute variable in PowerShell SQL query

人盡茶涼 提交于 2021-02-10 18:48:47
问题 I need to use a variable in my SQL query. This is my script: function SQLQueryWriteToFile([string]$SQLquery, [string]$extractFile, [string]$facility) { #create sql connection to connect to the sql DB $sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnection.ConnectionString = "Server=blah;Database=blah_Test;User ID=blah;Password=blah" $sqlConnection.Open() #Create a SqlCommand object to define the query $sqlCmd = New-Object System.Data.SqlClient.SqlCommand $sqlCmd

JAVA pass column of 2d array as 1d array

情到浓时终转凉″ 提交于 2021-02-10 06:16:53
问题 I need to pass a column of 2d array as 1d array. I have made this example to explain, and i don't know how to call print function. public static void main(String[] args) { double[][] matrix = {{ 0,1,2}, {3,4,5}, }; } public void print(double[] vector){ for(int i = 0; i< vector.length ; i++){ System.out.print(vector[i]); } } how can i do? 回答1: I need to pass a column of 2d array as 1d array. No directly you can not call method with 2D array as your method takes parameter double[] and not

JAVA pass column of 2d array as 1d array

家住魔仙堡 提交于 2021-02-10 06:16:03
问题 I need to pass a column of 2d array as 1d array. I have made this example to explain, and i don't know how to call print function. public static void main(String[] args) { double[][] matrix = {{ 0,1,2}, {3,4,5}, }; } public void print(double[] vector){ for(int i = 0; i< vector.length ; i++){ System.out.print(vector[i]); } } how can i do? 回答1: I need to pass a column of 2d array as 1d array. No directly you can not call method with 2D array as your method takes parameter double[] and not

How to pass vector parameter to OpenCL kernel in C?

只谈情不闲聊 提交于 2021-02-07 08:26:03
问题 I'm having trouble passing a vector type (uint8) parameter to an OpenCL kernel function from the host code in C. In the host I've got the data in an array: cl_uint dataArr[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; (My real data is more than just [1, 8]; this is just for ease of explanation.) I then transfer the data over to a buffer to be passed to the kernel: cl_mem kernelInputData = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*8, dataArr, NULL); Next, I pass this

How to pass vector parameter to OpenCL kernel in C?

喜夏-厌秋 提交于 2021-02-07 08:24:05
问题 I'm having trouble passing a vector type (uint8) parameter to an OpenCL kernel function from the host code in C. In the host I've got the data in an array: cl_uint dataArr[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; (My real data is more than just [1, 8]; this is just for ease of explanation.) I then transfer the data over to a buffer to be passed to the kernel: cl_mem kernelInputData = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*8, dataArr, NULL); Next, I pass this

How to pass parameters to an eval based function inJavascript

两盒软妹~` 提交于 2021-02-07 07:11:27
问题 I am storing function body in string with function name. function fnRandom(lim){ var data=[]; for(var i=0;i<lim;i++) { data=data.concat(Math.floor((Math.random() * 100) + 1)); } return data; } After selecting the functionName from a drop down I use eval to execute function body. JSON.stringify(eval(this.selectedFunction.body)); I want to pass 'lim' to this execution or can I use functionName as initiating point for execution somehow? 回答1: Use Function constructor var body = "console.log

How to check in python that at least one of the default parameters of the function specified

北城以北 提交于 2021-02-04 14:58:08
问题 What is the best practice in python to check if at least one of the default parameters of the function is specified? Let's suppose we have some function: def some_function(arg_a=None, arg_b=None, arg_c=False) with some default parameters. In my case, I need to check if either arg_a or arg_b is specified. So I thought of implementing something like this: def some_function(arg_a=None, arg_b=None, arg_c=False): ... if arg_a is not None: ... elif arg_b is not None: ... else: raise ValueError(