Tutorial by Examples: er

Const baseString As String = "Hello World" Dim byteLength As Long byteLength = LenB(baseString) 'byteLength = 22
When checking if a string is zero-length, it is better practice, and more efficient, to inspect the length of the string rather than comparing the string to an empty string. Const myString As String = vbNullString 'Prefer this method when checking if myString is a zero-length string If Len(mySt...
One common scenario is to wait for a number of requests to finish before continuing. This can be accomplished using the forkJoin method. In the following example, forkJoin is used to call two methods that return Observables. The callback specified in the .subscribe method will be called when both O...
Queries can be performed in two ways, both of which return an ADO Recordset object which is a collection of returned rows. Note that both of the examples below use the OpenDatabaseConnection function from the Making a connection to a data source example for the purpose of brevity. Remember that the...
Any time SQL executed through an ADO connection needs to contain user input, it is considered best practice to parameterize it in order to minimize the chance of SQL injection. This method is also more readable than long concatenations and facilitates more robust and maintainable code (i.e. by using...
Const string1 As String = "foo" Const string2 As String = "bar" Const string3 As String = "fizz" Dim concatenatedString As String 'Concatenate two strings concatenatedString = string1 & string2 'concatenatedString = "foobar" 'Concatenate three s...
Python uses internal caching for a range of integers to reduce unnecessary overhead from their repeated creation. In effect, this can lead to confusing behavior when comparing integer identities: >>> -8 is (-7 - 1) False >>> -3 is (-2 - 1) True and, using another example: ...
Dim lineOfHyphens As String 'Assign a string with 80 repeated hyphens lineOfHyphens = String$(80, "-")
Dim stringOfSpaces As String 'Assign a string with 255 repeated spaces using Space$ stringOfSpaces = Space$(255) 'Assign a string with 255 repeated spaces using String$ stringOfSpaces = String$(255, " ")
The purpose of this example is to show how we can realize the Strategy pattern using Java 8 functional interfaces. We will start with a simple use case codes in classic Java, and then recode it in the Java 8 way. The example problem we using is a family of algorithms (strategies) that describe dif...
from datetime import timedelta from django.utils import timezone from psycopg2.extras import DateTimeTZRange # To create a "period" object we will use psycopg2's DateTimeTZRange # which takes the two datetime bounds as arguments period_start = timezone.now() period_end = period_s...
Use assert_raise to test if an exception was raised. assert_raise takes in an Exception and a function to be executed. test "invalid block size" do assert_raise(MerkleTree.ArgumentError, (fn() -> MerkleTree.new ["a", "b", "c"] end)) end Wrap a...
Use defdelegate to define functions that delegate to functions of the same name defined in another module: defmodule Math do defdelegate pi, to: :math end iex> Math.pi 3.141592653589793
Inheritance the a fundamental mechanism of CSS by which the computed values of some properties of an element are applied to its' children. This is particularly useful when you want to set a global style to your elements rather than having to set said properties to each and every element in your mark...
Some properties are not automatically inherited from an element down to its' children. This is because those properties are typically desired to be unique to the element (or selection of elements) to which the property is applied to. Common such properties are margin, padding, background, display, e...
Simple item insertion can be done with Array.prototype.splice method: arr.splice(index, 0, item); More advanced variant with multiple arguments and chaining support: /* Syntax: array.insert(index, value1, value2, ..., valueN) */ Array.prototype.insert = function(index) { this.splice.a...
The first step is to import Platform from the 'react-native' package like so: import { Platform } from 'react-native' After you've done that, you can go ahead and access the OS type through Platform.OS allowing you to use it in conditional statements like const styles = StyleSheet.create({ h...
Used to declare an object or function that is defined elsewhere (and that has external linkage). In general, it is used to declare an object or function to be used in a module that is not the one in which the corresponding object or function is defined: /* file1.c */ int foo = 2; /* Has externa...
Hints to the compiler that access to an object should be as fast as possible. Whether the compiler actually uses the hint is implementation-defined; it may simply treat it as equivalent to auto. The only property that is definitively different for all objects that are declared with register is that...
$ react-native start On latest version of React Native, no need to run the packager. It will run automatically. By default this starts the server at port 8081. To specify which port the server is on $ react-native start --port PORTNUMBER

Page 152 of 417