optional-parameters

Optional params in Go?

梦想与她 提交于 2019-12-14 03:34:28
问题 I know that there aren't any optional params in the latest version of Go . But there are quite a lot cases when they are really helpful. Consider oversimplified example: func getFullName(firstName string, lastName string, maybeMiddleName func() (bool, string)) string { if ok, middleName:= maybeMiddleName(); ok { return firstName + " " + middleName + " " + lastName } return firstName + " " + lastName } That looks fine enough, thought requires a lot verbosity on a client side: whenever

SSRS Parameters - Toggle a parameter's NULL checkbox depending on value other parameter(s) NULL checkboxes

試著忘記壹切 提交于 2019-12-13 18:18:04
问题 In MS SQL Server Report Builder 3.0, I have an SSRS report with 3 parameters: start date (date) end date (date) last number of days (integer) My Stored Procedure needs either a Date Range OR the last number of days, not all 3 (they are set to NULL by default). I want to be able to toggle a parameters NULL checkbox (tick/untick) based on the value of another parameter, eg: last # days has NULL ticked, then untick NULL checkboxes for the date range (start & end date) & vice versa. Any ideas on

Only pass parameter if value supplied

霸气de小男生 提交于 2019-12-13 15:13:53
问题 Background I've created a wrapper function around Write-EventLog so that I can easily call it without having to concern myself with checking for & creating an event log/source each time. By simply adding a -Force parameter, I want it to create the log if it doesn't exist; if I don't add that parameter it should behave as normal (which reduces overhead of multiple checks if called from code where I know that log will exist). I've copied the list of parameters available to write-eventlog such

Handing optional parameters to subroutines [duplicate]

依然范特西╮ 提交于 2019-12-13 04:23:08
问题 This question already has an answer here : Is it necessary to check an optional argument before passing it to another optional argument? (1 answer) Closed last year . I have two subroutine. One calls the other and the both have the same optional parameter: program main call a() call a(7) contains subroutine a(var) implicit none integer, intent(in), optional :: var call b(var) end subroutine subroutine b(var) implicit none integer, intent(in), optional :: var if(present(var)) then write (*,*)

Assigning default value for type

不问归期 提交于 2019-12-13 00:25:27
问题 How to assign default value to following type of Oracle statement into PostgreSQL 9.3? CREATE OR REPLACE FUNCTION(.... ... DECLARE v_var Table01.column01%TYPE := 'SLOW'; BEGIN ... ... END; 回答1: Postgres allows to provide parameter defaults , which kick in for missing parameters in the function call. Only allowed for parameters at the end of the list . Example: CREATE OR REPLACE FUNCTION foo ( param1 int , v_char tbl01.col01%TYPE DEFAULT 'foo' ) ... -- no need to DECLARE anything else. BEGIN .

Passing of variable arguments in C

非 Y 不嫁゛ 提交于 2019-12-12 19:20:35
问题 Does anybody know how variable arguments are passed in classic C? I did some debugging today and most regular arguments are passed via stack. However it seems that this does not apply for variable arguments. Are those parameters stored somewhere else like constant strings? Thanks in advance! 回答1: They are very often passed on the stack. What you are looking for is ABI specifications for the platform you are using. For the AMD64 platform, have a look for example here. 回答2: It depends on the

Calling a WebMethod from a web reference with optional parameters in C#

孤人 提交于 2019-12-12 13:32:02
问题 I have created a dummy web service with 2 optional parameters using the .Net Webservices, however in the real product we are going to have a lot more optional parameters(think: filters for a query). The problem is that it is not possible to leave out the optional parameters when calling the webservice, meaning there will be a potential dozens of NULL values in every call to the webservice when developing against the real webservice. Right now this dummy webservice consists of only this, to

MVC Routing get rid of /Index in URL

不打扰是莪最后的温柔 提交于 2019-12-12 10:59:11
问题 I have a dynamic list of ActionLinks generated at run time like this: @Html.ActionLink(x.Name, "Index", "User", new { x.ID }, null) so I'm hitting the Index method on the User controller. I also have my RouteConfig.cs (it's an MVC4 app) set as follows: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );

Can you use optional parameters in a WCF service method? [duplicate]

牧云@^-^@ 提交于 2019-12-12 07:45:35
问题 This question already has answers here : Named and optional parameters, and WCF (3 answers) Closed 5 years ago . I've seen posts like this and this but they are each a few years old. Can I do something like this? [OperationContract] [FaultContract(typeof(MyCustomFault))] List<InventoryPart> SelectMany(string partialPartNumber, string division = null); 回答1: You can't. There are many restrictions on WCF regarding the method signatures; some restrictions are because of the host mechanism, and

Discover SQL Server procedure default parameters using SYS or INFORMATION_SCHEMA tables

别等时光非礼了梦想. 提交于 2019-12-12 03:14:38
问题 Like Oracle, SQL Server supports parameter defaults in stored procedures. Oracle syntax: CREATE OR REPLACE PROCEDURE p_default ( p_in_number IN number := 0, p_out_number OUT number, p_in_varchar IN varchar2 := '0', p_out_varchar OUT varchar2, p_in_date IN date := date '1981-07-10', p_out_date OUT date ) SQL Server syntax: CREATE PROCEDURE p_default ( @p_in_number INTEGER = 0, @p_out_number INTEGER OUT, @p_in_varchar VARCHAR(10) = '0', @p_out_varchar VARCHAR(10) OUT, @p_in_date DATE = '1981-07