Optional parameters in SQL Server stored procedure

You can declare it like this: CREATE PROCEDURE MyProcName @Parameter1 INT = 1, @Parameter2 VARCHAR (100) = ‘StringValue’, @Parameter3 VARCHAR (100) = NULL AS /* Check for the NULL / default value (indicating nothing was passed) */ if (@Parameter3 IS NULL) BEGIN /* Whatever code you desire for a missing parameter */ INSERT INTO …….. … Read more

How does one declare optional methods in a Swift protocol?

1. Using default implementations (preferred). protocol MyProtocol { func doSomething() } extension MyProtocol { func doSomething() { /* return a default value or just leave empty */ } } struct MyStruct: MyProtocol { /* no compile error */ } Advantages No Objective-C runtime is involved (well, no explicitly at least). This means you can conform … Read more

Optional parameters in functions and their mutable default values [duplicate]

Good doc from PyCon a couple years back – Default parameter values explained. But basically, since lists are mutable objects, and keyword arguments are evaluated at function definition time, every time you call the function, you get the same default value. The right way to do this would be: def F(a, b=None): if b is … Read more

How to add an optional parameters/default value parameters in VB function?

Use the Optional keyword and supply a default value. Optional parameters must be the last parameters defined, to avoid creating ambiguous function signatures. Sub MyMethod(ByVal Param1 As String, Optional ByVal FlagArgument As Boolean = True) If FlagArgument Then ‘Do something special Console.WriteLine(Param1) End If End Sub Call it like this: MyMethod(“test1”) Or like this: MyMethod(“test2”, … Read more

Optional dependencies in AngularJS

Apparently not using automatic injection. However, you can inject the injector and check for the service: myApp.controller(‘MyController’, [ ‘$scope’, ‘$injector’, ‘firstRequiredService’, ‘secondRequiredService’, function ($scope, $injector, firstRequiredService, secondRequiredService) { if ($injector.has(‘firstOptionalService’)) { var firstOptionalService = $injector.get(‘firstOptionalService’); } } ]);

Passing in NULL as a parameter in ES6 does not use the default parameter when one is provided

This is not that obvious I’ve read some comments of why undefined is completely different than null and that’s why it explains the current behavior of default parameters. One could argue that explicitly passing undefined should not trigger the default value substitution because when I have a function: const f = (x = ‘default’) => … Read more

Groovy method with optional parameters

Can’t be done as it stands… The code def myMethod(pParm1=’1′, pParm2=’2′){ println “${pParm1}${pParm2}” } Basically makes groovy create the following methods: Object myMethod( pParm1, pParm2 ) { println “$pParm1$pParm2” } Object myMethod( pParm1 ) { this.myMethod( pParm1, ‘2’ ) } Object myMethod() { this.myMethod( ‘1’, ‘2’ ) } One alternative would be to have an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)