Tutorial by Examples: ch

Swift textView.textColor = UIColor.red Objective-C textView.textColor = [UIColor redColor];
Map<String, String> num = new HashMap<>(); num.put("one", "first"); if (num.containsKey("one")) { System.out.println(num.get("one")); // => first } Maps can contain null values For maps, one has to be carrefull not to confuse &quot...
After creating a new model or modifying existing models, you will need to generate migrations for your changes and then apply the migrations to the specified database. This can be done by using the Django's built-in migrations system. Using the manage.py utility when in the project root directory: ...
While many people think that ^ means the start of a string, it actually means start of a line. For an actual start of string anchor use, \A. The string hello\nworld (or more clearly) hello world Would be matched by the regular expressions ^h, ^w and \Ah but not by \Aw
ForEach has two different meanings in PowerShell. One is a keyword and the other is an alias for the ForEach-Object cmdlet. The former is described here. This example demonstrates printing all items in an array to the console host: $Names = @('Amy', 'Bob', 'Celine', 'David') ForEach ($Name in $...
For security reasons, PowerShell is set up by default to only allow signed scripts to execute. Executing the following command will allow you to run unsigned scripts (you must run PowerShell as Administrator to do this). Set-ExecutionPolicy RemoteSigned Another way to run PowerShell scripts is t...
class Animal def method_missing(method, *args, &block) "Cannot call #{method} on Animal" end end => Animal.new.say_moo > "Cannot call say_moo on Animal"
To broaden the selections of a structured query language (SQL-SELECT) statement, wildcard characters, the percent sign (%) and the underscore (_), can be used. The _ (underscore) character can be used as a wildcard for any single character in a pattern match. Find all employees whose Fname start w...
Match any single character within the specified range (e.g.: [a-f]) or set (e.g.: [abcdef]). This range pattern would match "gary" but not "mary": SELECT * FROM Employees WHERE FName LIKE '[a-g]ary' This set pattern would match "mary" but not "gary": SEL...
Generally, the syntax is: SELECT <column names> FROM <table name> WHERE <condition> For example: SELECT FirstName, Age FROM Users WHERE LastName = 'Smith' Conditions can be complex: SELECT FirstName, Age FROM Users WHERE LastName = 'Smith' AND (City = 'New York' OR C...
If you are matching on an Option type: def f(x: Option[Int]) = x match { case Some(i) => doSomething(i) case None => doSomethingIfNone } This is functionally equivalent to using fold, or map/getOrElse: def g(x: Option[Int]) = x.fold(doSomethingIfNone)(doSomething) def h(x: ...
When a column name matches a reserved keyword, standard SQL requires that you enclose it in double quotation marks: SELECT "ORDER", ID FROM ORDERS Note that it makes the column name case-sensitive. Some DBMSes have proprietary ways of quoting names. For example, SQL Serve...
When pattern matching an object whose type is a sealed trait, Scala will check at compile-time that all cases are 'exhaustively matched': sealed trait Shape case class Square(height: Int, width: Int) extends Shape case class Circle(radius: Int) extends Shape case object Point extends Shape ...
In many cases, the Razor parser is smart enough to figure out when the @ sign is meant to be used as part of code, as opposed to being part of something like an email address. In the example below, escaping the @ sign is not necessary: <p>Reach out to us at [email protected]</p> Howev...
Jumping to characters f{char} - move to the next occurrence of {char} to the right of the cursor on the same line F{char} - move to the next occurrence of {char} to the left of the cursor on the same line t{char} - move to the left of the next occurrence of {char} to the right of the cursor on th...
// The Option type can either contain Some value or None. fn find(value: i32, slice: &[i32]) -> Option<usize> { for (index, &element) in slice.iter().enumerate() { if element == value { // Return a value (wrapped in Some). return Some(index);...
To apply a function to every item in an array, use array_map(). This will return a new array. $array = array(1,2,3,4,5); //each array item is iterated over and gets stored in the function parameter. $newArray = array_map(function($item) { return $item + 1; }, $array); $newArray now is a...
The ForEach-Object cmdlet works similarly to the foreach statement, but takes its input from the pipeline. Basic usage $object | ForEach-Object { code_block } Example: $names = @("Any","Bob","Celine","David") $names | ForEach-Object { "H...
MKLocalSearch allows users to search for location using natural language strings like "gym". Once the search get completed, the class returns a list of locations within a specified region that match the search string. Search results are in form of MKMapItem within MKLocalSearchResponse ob...
This a basic example aimed at new users. It does not focus on explaining the difference between char and cellstring. It might happen that you want to get rid of the ' in your strings, although you never added them. In fact, those are artifacts that the command window uses to distinguish between ...

Page 10 of 109