Tutorial by Examples

#! /bin/bash i=0 while [ $i -lt 5 ] #While i is less than 5 do echo "i is currently $i" i=$[$i+1] #Not the lack of spaces around the brackets. This makes it a not a test expression done #ends the loop Watch that there are spaces around the brackets during the test (aft...
#! /bin/bash for i in 1 "test" 3; do #Each space separated statement is assigned to i echo $i done Other commands can generate statements to loop over. See "Using For Loop to Iterate Over Numbers" example. This outputs: 1 test 3
#! /bin/bash for i in {1..10}; do # {1..10} expands to "1 2 3 4 5 6 7 8 9 10" echo $i done This outputs the following: 1 2 3 4 5 6 7 8 8 10
In the same module Inside a module named "MyModule", Xcode generates a header named MyModule-Swift.h which exposes public Swift classes to Objective-C. Import this header in order to use the Swift classes: // MySwiftClass.swift in MyApp import Foundation // The class must be `public`...
If MyFramework contains Objective-C classes in its public headers (and the umbrella header), then import MyFramework is all that's necessary to use them from Swift. Bridging headers A bridging header makes additional Objective-C and C declarations visible to Swift code. When adding project files, ...
Supplying pow() with 3 arguments pow(a, b, c) evaluates the modular exponentiation ab mod c: pow(3, 4, 17) # 13 # equivalent unoptimized expression: 3 ** 4 % 17 # 13 # steps: 3 ** 4 # 81 81 % 17 # 13 For built-in types using modular exponentiation is only possible...
// use Write trait that contains write() function use std::io::Write; fn main() { std::io::stdout().write(b"Hello, world!\n").unwrap(); } The std::io::Write trait is designed for objects which accept byte streams. In this case, a handle to standard output is acquired with ...
Concatenate strings with the + operator to produce a new string: let name = "John" let surname = "Appleseed" let fullName = name + " " + surname // fullName is "John Appleseed" Append to a mutable string using the += compound assignment operator, or usi...
The -import-objc-header flag specifies a header for swiftc to import: // defs.h struct Color { int red, green, blue; }; #define MAX_VALUE 255 // demo.swift extension Color: CustomStringConvertible { // extension on a C struct public var description: String { return &q...
A module map can simply import mymodule by configuring it to read C header files and make them appear as Swift functions. Place a file named module.modulemap inside a directory named mymodule: Inside the module map file: // mymodule/module.modulemap module mymodule { header "defs.h&q...
public class TrustLoader { public static void main(String args[]) { try { //Gets the inputstream of a a trust store file under ssl/rpgrenadesClient.jks //This path refers to the ssl folder in the jar file, in a jar file in the same directory ...
A rebase switches the meaning of "ours" and "theirs": git checkout topic git rebase master # rebase topic branch on top of master branch Whatever HEAD's pointing to is "ours" The first thing a rebase does is resetting the HEAD to master; before cherry-picking...
You have up to 5 sources for git configuration: 6 files: %ALLUSERSPROFILE%\Git\Config (Windows only) (system) <git>/etc/gitconfig, with <git> being the git installation path. (on Windows, it is <git>\mingw64\etc\gitconfig) (system) $XDG_CONFIG_HOME/git/config (Linux/Mac on...
Using the strtotime() function combined with date() you can parse different English text descriptions to dates: // Gets the current date echo date("m/d/Y", strtotime("now")), "\n"; // prints the current date echo date("m/d/Y", strtotime("10 September 2...
Check whether a string is empty: if str.isEmpty { // do something if the string is empty } // If the string is empty, replace it with a fallback: let result = str.isEmpty ? "fallback string" : str Check whether two strings are equal (in the sense of Unicode canonical equivale...
A Swift String is made of Unicode code points. It can be decomposed and encoded in several different ways. let str = "ที่👌①!" Decomposing Strings A string's characters are Unicode extended grapheme clusters: Array(str.characters) // ["ที่", "👌", "①", ...
The following is an example that displays 5 one-dimensional random walks of 200 steps: y = cumsum(rand(200,5) - 0.5); plot(y) legend('1', '2', '3', '4', '5') title('random walks') In the above code, y is a matrix of 5 columns, each of length 200. Since x is omitted, it defaults to the row n...
Per paragraph 6.5/5 of both C99 and C11, evaluation of an expression produces undefined behavior if the result is not a representable value of the expression's type. For arithmetic types, that's called an overflow. Unsigned integer arithmetic does not overflow because paragraph 6.2.5/9 applies, ca...
font-family: 'Segoe UI', Tahoma, sans-serif; The browser will attempt to apply the font face "Segoe UI" to the characters within the elements targeted by the above property. If this font is not available, or the font does not contain a glyph for the required character, the browser wil...
The localStorage object provides persistent (but not permanent - see limits below) key-value storage of strings. Any changes are immediately visible in all other windows/frames from the same origin. The stored values persistent indefinitely unless the user clears saved data or configures an expirati...

Page 52 of 1336