Tutorial by Examples: co

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...
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...
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...
import re precompiled_pattern = re.compile(r"(\d+)") matches = precompiled_pattern.search("The answer is 41!") matches.group(1) # Out: 41 matches = precompiled_pattern.search("Or was it 42?") matches.group(1) # Out: 42 Compiling a pattern allows it to be r...
The built-in function len returns the number of elements in a map m := map[string]int{} len(m) // 0 m["foo"] = 1 len(m) // 1 If a variable points to a nil map, then len returns 0. var m map[string]int len(m) // 0
In a normal string, the backslash character is the escape character, which instructs the compiler to look at the next character(s) to determine the actual character in the string. (Full list of character escapes) In verbatim strings, there are no character escapes (except for "" which is ...
BuildConfigField Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build fla...
You can combine object initializers with constructors to initialize types if necessary. Take for example a class defined as such: public class Book { public string Title { get; set; } public string Author { get; set; } public Book(int id) { //do things } // the...
length counts the occurences of elements a in a foldable structure t a. ghci> length [7, 2, 9] -- t ~ [] 3 ghci> length (Right 'a') -- t ~ Either e 1 -- 'Either e a' may contain zero or one 'a' ghci> length (Left "foo") -- t ~ Either String 0 ghci> length (3, True) ...
When the following is compiled, it will return a different value depending on which directives are defined. // Compile with /d:A or /d:B to see the difference string SomeFunction() { #if A return "A"; #elif B return "B"; #else return "C"; #endif ...
Compiler warnings can be generated using the #warning directive, and errors can likewise be generated using the #error directive. #if SOME_SYMBOL #error This is a compiler Error. #elif SOME_OTHER_SYMBOL #warning This is a compiler Warning. #endif
Line #line controls the line number and filename reported by the compiler when outputting warnings and errors. void Test() { #line 42 "Answer" #line filename "SomeFile.cs" int life; // compiler warning CS0168 in "SomeFile.cs" at Line 42 #line defa...
Array types inherit their equals() (and hashCode()) implementations from java.lang.Object, so equals() will only return true when comparing against the exact same array object. To compare arrays for equality based on their values, use java.util.Arrays.equals, which is overloaded for all array types...
Setting values Using Unicode directly var str: String = "I want to visit 北京, Москва, मुंबई, القاهرة, and 서울시. 😊" var character: Character = "🌍" Using hexadecimal values var str: String = "\u{61}\u{5927}\u{1F34E}\u{3C0}" // a大🍎π var character: Character = &quo...
using System; using System.Dynamic; dynamic info = new ExpandoObject(); info.Id = 123; info.Another = 456; Console.WriteLine(info.Another); // 456 Console.WriteLine(info.DoesntExist); // Throws RuntimeBinderException
To remove a cookie, set the expiry timestamp to a time in the past. This triggers the browser's removal mechanism: setcookie('user', '', time() - 3600, '/'); When deleting a cookie make sure the path and domain parameters of setcookie() matches the cookie you're trying to delete or a new cooki...
A view can be a really complex query(aggregations, joins, subqueries, etc). Just be sure you add column names for everything you select: Create VIEW dept_income AS SELECT d.Name as DepartmentName, sum(e.salary) as TotalSalary FROM Employees e JOIN Departments d on e.DepartmentId = d.id GROUP BY...
The following syntax indicate that a class adopts a protocol, using angle brackets. @interface NewClass : NSObject <NewProtocol> ... @end This means that any instance of NewClass will respond to methods declared in its interface but also it will provide an implementation for all the requ...
VoiceOver can navigate many apps on iOS because most UIKit classes implement UIAccessibilityProtocol. Features that don’t represent onscreen elements using UIView, including apps that leverage Core Graphics or Metal to perform drawing, must describe these elements for accessibility. As of iOS 8.0, t...
List Comprehensions can use nested for loops. You can code any number of nested for loops within a list comprehension, and each for loop may have an optional associated if test. When doing so, the order of the for constructs is the same order as when writing a series of nested for statements. The ge...

Page 18 of 248