parameters

Is the use of `const` dogmatic or rational?

喜欢而已 提交于 2019-12-20 10:08:12
问题 In Delphi you can speed up your code by passing parameters as const , e.g. function A(const AStr: string): integer; //or function B(AStr: string): integer; Suppose both functions have the same code inside, the speed difference between them is negligible and I doubt it can even be measured with a cycle-counter like: function RDTSC: comp; var TimeStamp: record case byte of 1: (Whole: comp); 2: (Lo, Hi: Longint); end; begin asm db $0F; db $31; mov [TimeStamp.Lo], eax mov [TimeStamp.Hi], edx end;

Passing single object vs. passing multiple parameters

走远了吗. 提交于 2019-12-20 10:05:23
问题 Suppose I have the following Class A { Foo getFoo(); Bar getBar(); Baz getBaz(); } And I need to define a function doStuff that uses Foo , Bar , Baz of one object and does some stuff I'm struggling between which method of implementing doStuff is better (suppose it would be undesirable to place doStuff inside class A ) Method A void doStuff(Foo foo, Bar bar, Baz baz) { //some operation } or Method B void doStuff(A a) { Foo foo = a.getFoo(); Bar bar = a.getBar(); Baz baz = a.getBaz(); //some

Check if parameter exists in Expression Language [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-20 09:12:45
问题 This question already has answers here : Evaluate empty or null JSTL c tags (8 answers) Closed 3 years ago . <c:if test="${param.username}" > </c:if> How do I check if param.username exists?? 回答1: Use the not empty check. <c:if test="${not empty param.username}" > </c:if> Edit: If you have a parameter of the form ?username (no value), it is safer to use ${param.username ne null} 回答2: If you want to check if parameter exists, just test if it is not null, in your case: <c:if test="${param

What happens when I call a Javascript function which takes parameters, without supplying those parameters?

删除回忆录丶 提交于 2019-12-20 09:05:35
问题 What happens when I call a Javascript function which takes parameters, without supplying those parameters? 回答1: Set to undefined. You don't get an exception. It can be a convenient method to make your function more versatile in certain situations. Undefined evaluates to false, so you can check whether or not a value was passed in. 回答2: javascript will set any missing parameters to the value undefined . function fn(a) { console.log(a); } fn(1); // outputs 1 on the console fn(); // outputs

Difference between arguments/parameters in C# [duplicate]

橙三吉。 提交于 2019-12-20 08:56:56
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What's the difference between an argument and a parameter? What is the difference between an argument & a parameter in C#? Are they the same thing? 回答1: Well, neither keyword is present in the language, so the question is somewhat vague. The best that can be done is to look how each term is used in C# language specification (1.6.6.1 "Parameters"): Parameters are used to pass values or variable references to

How to define a class of a parameter that is not present in the select?

*爱你&永不变心* 提交于 2019-12-20 07:58:20
问题 I got a problem with the Jasper Studio application. I want to make a parameter, but I don't find java.lang.collection in the class select. What's the solution so that java.lang.collection is in the application 回答1: You have 2 options Type the class directly (it's an select, but you can also type) Press the button next to the select it will open a Dialog as shown in image, then type your class and press "OK" I'm not sure what class java.lang.collection is I guess your are looking for java.util

How can i change a variable that is passed to a function as a parameter?

拟墨画扇 提交于 2019-12-20 07:44:16
问题 I am trying to change some variables inside a struct by using a function that returns void. The function takes a Struct member as a parameter, an array of structs and a size. The function has some code, that in the end, changes some variables inside the struct member. However, I know that when you pass something into a function as a parameter, you are working with a copy and not the original. And therefore, the changes that are made to the struct member, will not be "saved". I have done some

BASH: getopts with default parameters value

非 Y 不嫁゛ 提交于 2019-12-20 07:27:12
问题 I've got another bash-script problem I simply couldn't solve. It's my simplified script showing the problem: while getopts "r:" opt; do case $opt in r) fold=/dev dir=${2:-fold} a=`find $dir -type b | wc -l` echo "$a" ;; esac done I calling it by: ./sc.sh -r /bin and it's work, but when I don't give a parameter it doesn't work: ./sc.sh -r I want /dev to be my default parameter $2 in this script. 回答1: There may be other parameters before, don't hard-code the parameter number ($2). The getopts

Can't get value of Ninject ConstructorArgument (passed in as parameter to kernel.Get)

旧巷老猫 提交于 2019-12-20 07:19:40
问题 Having trouble getting the value of a ConstructorArgument parameter passed to kernel.Get(). I want to use the parameter's value to determine which of two string values will be passed into the constructor. The parameter is in fact there when expected, I just can't get at its value. I end up with a null ref exception after calling the parameter's GetValue method: namespace MyNS.DBProviders { public abstract class DBProviderBase { private ObjectContext _db; public DBProviderBase(ObjectContext db

How to set parameters for SqlDataSource UpdateCommand

一笑奈何 提交于 2019-12-20 07:19:19
问题 For a Gridview: I am trying to use a stored procedure for the first time in a SQLDataSource for the UpdateCommand: <asp:SqlDataSource ID="TECT_DataSource" runat="server" ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>" ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>" SelectCommand="SELECT MPID, User_Id, Last_Name, First_Name FROM Scripts.vw_Tect_Exam" UpdateCommand="P_TECT_UPD_EXAM_ID" UpdateCommandType="StoredProcedure"> <UpdateParameters> <asp