Tutorial by Examples

The DATEDIF function returns the difference between two date values, based on the interval specified. It is provided for compatibility with Lotus 1-2-3. The DATEDIF function cannot be found on the function list and autocomplete and screen tips are unavailable. Note: It is pronounced "date diff&...
You can call memset to zero out a string (or any other memory block). Where str is the string to zero out, and n is the number of bytes in the string. #include <stdlib.h> /* For EXIT_SUCCESS */ #include <stdio.h> #include <string.h> int main(void) { char str[42] = &quo...
Some example cases when the result is an optional. var result: AnyObject? = someMethod() switch result { case nil: print("result is nothing") case is String: print("result is a String") case _ as Double: print("result is not nil, any value that is a Dou...
If you want to mimic HTML form POST action, you can use cURL. // POST data in array $post = [ 'a' => 'apple', 'b' => 'banana' ]; // Create a new cURL resource with URL to POST $ch = curl_init('http://www.example.com'); // We set parameter CURLOPT_RETURNTRANSFER to read outp...
Before C++17, having pointers with a value of nullptr commonly represented the absence of a value. This is a good solution for large objects that have been dynamically allocated and are already managed by pointers. However, this solution does not work well for small or primitive types such as int, w...
Before C++17, a function typically represented failure in one of several ways: A null pointer was returned. e.g. Calling a function Delegate *App::get_delegate() on an App instance that did not have a delegate would return nullptr. This is a good solution for objects that have been dynamicall...
In most examples, the class naming convention is used to define an Aurelia Custom Element. However, Aurelia also provides a decorator that can be used to decorate a class. The class is again treated as a custom element by Aurelia then. The value supplied to the decorator becomes the name of the cus...
Usually data sent in a POST request is structured key/value pairs with a MIME type of application/x-www-form-urlencoded. However many applications such as web services require raw data, often in XML or JSON format, to be sent instead. This data can be read using one of two methods. php://input is a...
This illustrates that union members shares memory and that struct members does not share memory. #include <stdio.h> #include <string.h> union My_Union { int variable_1; int variable_2; }; struct My_Struct { int variable_1; int variable_2; }; int main (void) { ...
Some C implementations permit code to write to one member of a union type then read from another in order to perform a sort of reinterpreting cast (parsing the new type as the bit representation of the old one). It is important to note however, this is not permitted by the C standard current or pas...
You can declare multiple constants within the same const block: const ( Alpha = "alpha" Beta = "beta" Gamma = "gamma" ) And automatically increment constants with the iota keyword: const ( Zero = iota // Zero == 0 One // One == 1...
Assert.That(actual, Is.EqualTo(expected));
Large fluent assertions do become harder to read, but when combined with classes that have good implementations of ToString(), they can generate very useful error messages. [Test] public void AdvancedContraintsGiveUsefulErrorMessages() { Assert.That(actualCollection, Has .Count.Equa...
Invoking a function as a method of an object the value of this will be that object. var obj = { name: "Foo", print: function () { console.log(this.name) } } We can now invoke print as a method of obj. this will be obj obj.print(); This will thus log: Foo...
Invoking a function as an anonymous function, this will be the global object (self in the browser). function func() { return this; } func() === window; // true 5 In ECMAScript 5's strict mode, this will be undefined if the function is invoked anonymously. (function () { "use...
When a function is invoked as a constructor with the new keyword this takes the value of the object being constructed function Obj(name) { this.name = name; } var obj = new Obj("Foo"); console.log(obj); This will log { name: "Foo" }
6 When using arrow functions this takes the value from the enclosing execution context's this (that is, this in arrow functions has lexical scope rather than the usual dynamic scope). In global code (code that doesn't belong to any function) it would be the global object. And it keeps that way, eve...
The apply and call methods in every function allow it to provide a custom value for this. function print() { console.log(this.toPrint); } print.apply({ toPrint: "Foo" }); // >> "Foo" print.call({ toPrint: "Foo" }); // >> "Foo" You mig...
The bind method of every function allows you to create new version of that function with the context strictly bound to a specific object. It is specially useful to force a function to be called as a method of an object. var obj = { foo: 'bar' }; function foo() { return this.foo; } fooOb...
Normally your tests should be created in such a way that execution order is no concern. However there is always going to be an edge case were you need to break that rule. The one scenario I came across was with R.NET whereby in a given process you can only initialize one R Engine and once disposed ...

Page 358 of 1336