Tutorial by Examples: c

String comparison uses the == operator between quoted strings. The != operator negates the comparison. if [[ "$string1" == "$string2" ]]; then echo "\$string1 and \$string2 are identical" fi if [[ "$string1" != "$string2" ]]; then echo &quot...
In helloJohn.sh: #!/bin/bash greet() { local name="$1" echo "Hello, $name" } greet "John Doe" # running above script $ bash helloJohn.sh Hello, John Doe If you don't modify the argument in any way, there is no need to copy it to a local variabl...
Gradients are new image types, added in CSS3. As an image, gradients are set with the background-image property, or the background shorthand. There are two types of gradient functions, linear and radial. Each type has a non-repeating variant and a repeating variant: linear-gradient() repeating-...
Some regular expression flavors allow named capture groups. Instead of by a numerical index you can refer to these groups by name in subsequent code, i.e. in backreferences, in the replace pattern as well as in the following lines of the program. Numerical indexes change as the number or arrangemen...
A description list (or definition list, as it was called before HTML5) can be created with the dl element. It consists of name-value groups, where the name is given in the dt element, and the value is given in the dd element. <dl> <dt>name 1</dt> <dd>value for 1</dd...
You define a map using the keyword map, followed by the types of its keys and its values: // Keys are ints, values are ints. var m1 map[int]int // initialized to nil // Keys are strings, values are ints. var m2 map[string]int // initialized to nil Maps are reference types, and once defined ...
One can declare and initialize a map in a single statement using a composite literal. Using automatic type Short variable declaration: mapIntInt := map[int]int{10: 100, 20: 100, 30: 1000} mapIntString := map[int]string{10: "foo", 20: "bar", 30: "baz"} mapStringInt :...
slice = append(slice, "hello", "world")
A useful tool in Java Concurrency is ThreadLocal – this allows you to have a variable that will be unique to a given thread. Thus, if the same code runs in different threads, these executions will not share the value, but instead each thread has its own variable that is local to the thread. For exa...
When two margins are touching each other vertically, they are collapsed. When two margins touch horizontally, they do not collapse. Example of adjacent vertical margins: Consider the following styles and markup: div{ margin: 10px; } <div> some content </div> <div&gt...
We can illustrate this problem with the following pseudo-code function foo() { global $bob; $bob->doSomething(); } Your first question here is an obvious one Where did $bob come from? Are you confused? Good. You've just learned why globals are confusing and considered a bad p...
Creating immutable arrays: NSArray *myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; // Using the array literal syntax: NSArray *myColors = @[@"Red", @"Green", @"Blue", @"Yellow"]; ...
NSArray *myColors = @[@"Red", @"Green", @"Blue", @"Yellow"]; // Preceding is the preferred equivalent to [NSArray arrayWithObjects:...] Getting a single item The objectAtIndex: method provides a single object. The first object in an NSArray is index 0. Si...
Table cells can span multiple columns or rows using the colspan and rowspan attributes. These attributes can be applied to <th> and <td> elements. <table> <tr> <td>row 1 col 1</td> <td>row 1 col 2</td> <td>row 1 c...
It’s a good practice to declare the primary language of the document in the html element: <html lang="en"> If no other lang attribute is specified in the document, it means that everything (i.e., element content and attribute text values) is in that language. If the document con...
The <section> element represents a generic section to thematically group content. Every section, typically, should be able to be identified with a heading element as a child of the section. You can use the <section> element within an <article> and vice-versa. Every section shou...
The construct (?R) is equivalent to (?0) (or \g<0>) - it lets you recurse the whole pattern: <(?>[^<>]+|(?R))+> This will match properly balanced angle brackets with any text in-between the brackets, like <a<b>c<d>e>.
You can recurse into a subpattern using the following constructs (depending on the flavor), assuming n is a capturing group number, and name the name of a capturing group. (?n) \g<n> \g'0' (?&name) \g<name> \g'name' (?P>name) The following pattern: \[(?<angle>&...
Subpatterns can be referenced with their relative group number: (?-1) will recurse into the previous group (?+1) will recurse into the next group Also usable with the \g<N> syntax.
To pass data from the current view controller back to the previous view controller, you can use the delegate pattern. This example assumes that you have made a segue in the Interface Builder and that you set the segue identifier to showSecondViewController. The outlets and actions must also be ho...

Page 60 of 826