Tutorial by Examples: arg

C++11 It's possible to write a generic function (for example min) which accepts various numerical types and arbitrary argument count by template meta-programming. This function declares a min for two arguments and recursively for more. template <typename T1, typename T2> auto min(const T1 &...
By default the Large Object Heap is not compacted unlike the classic Object Heap which can lead to memory fragmentation and further, can lead to OutOfMemoryExceptions Starting with .NET 4.5.1 there is an option to explicitly compact the Large Object Heap (along with a garbage collection): GCSettin...
We can omit the argument in the call if that argument is an Optional Argument Every Optional Argument has its own default value It will take default value if we do not supply the value A default value of a Optional Argument must be a Constant expression. Must be a value type such as enum or s...
To create a function which accepts an undetermined number of arguments, there are two methods depending on your environment. 5 Whenever a function is called, it has an Array-like arguments object in its scope, containing all the arguments passed to the function. Indexing into or iterating over th...
K&R void* is a catch all type for pointers to object types. An example of this in use is with the malloc function, which is declared as void* malloc(size_t); The pointer-to-void return type means that it is possible to assign the return value from malloc to a pointer to any other type of ob...
Custom events usually need custom event arguments containing information about the event. For example MouseEventArgs which is used by mouse events like MouseDown or MouseUp events, contains information about Location or Buttons which used to generate the event. When creating new events, to create a...
def foobar(foo=None, bar=None): return "{}{}".format(foo, bar) values = {"foo": "foo", "bar": "bar"} foobar(**values) # "foobar"
process.argv is an array containing the command line arguments. The first element will be node, the second element will be the name of the JavaScript file. The next elements will be any additional command line arguments. Code Example: Output sum of all command line arguments index.js var sum = 0...
ENV ENV <key> <value> ENV <key>=<value> ... The ENV instruction sets the environment variable <key> to the value . This value will be in the environment of all “descendant” Dockerfile commands and can be replaced inline in many as well. The ENV instruction has two...
// Get the battery API navigator.getBattery().then(function(battery) { if (battery.charging) { console.log("Battery is charging"); } else { console.log("Battery is discharging"); } });
// Get the battery API navigator.getBattery().then(function(battery) { console.log( "Battery will get fully charged in ", battery.chargingTime, " seconds" ); });
{ "description": "My awesome library", "dependencies": { "NETStandard.Library": "1.6.0" }, "frameworks": { "netstandard1.3": { } } } A library that targets netstandard1.3 can be used on any fr...
{ "description": "My awesome library", "dependencies": { }, "frameworks": { "net40": { }, "netstandard1.3": { "dependencies": { "NETStandard.Library": "1.6.0" ...
class MyHello { def sayHello() { "Hello, world" } } def cl = { sayHello() } cl() // groovy.lang.MissingMethodException cl.delegate = new MyHello() cl(); // "Hello, world" Used extensively by Groovy DSLs.
function transform(fn, arr) { let result = []; for (let el of arr) { result.push(fn(el)); // We push the result of the transformed item to result } return result; } console.log(transform(x => x * 2, [1,2,3,4])); // [2, 4, 6, 8] As you can see, our transform fun...
<svg> <defs> <linearGradient id='g' y1="100%" x2="100%"> <stop offset='0%' stop-color='yellow' /> <stop offset='100%' stop-color='green' /> </linearGradient> </defs> <rect width=...
proc myproc {} { puts "hi" } myproc # => hi An empty argument list (the second argument after the procedure name, "myproc") means that the procedure will not accept arguments.
proc myproc {alpha beta} { ... set foo $alpha set beta $bar ;# note: possibly useless invocation } myproc 12 34 ;# alpha will be 12, beta will be 34 If the argument list consists of words, those will be the names of local variables in the procedure, and their initi...
### Definition proc myproc {alpha {beta {}} {gamma green}} { puts [list $alpha $beta $gamma] } ### Use myproc A # => A {} green myproc A B # => A B green myproc A B C # => A B C This procedure accepts one, two, or three arguments: those parameters whose names are the fi...
proc myproc args { ... } proc myproc {args} { ... } ;# equivalent If the special parameter name args is the last item in the argument list, it receives a list of all arguments at that point in the command line. If there are none, the list is empty. There can be arguments, including optional one...

Page 5 of 13