Tutorial by Examples: ch

We can match on lists like any other data type, though they are somewhat unique, in that the constructor for building up lists is the infix function ::. (See the example Creating a list for more on how that works.) matchMyList : List SomeType -> SomeOtherType matchMyList myList = case myL...
A common pitfall of child classes is that, if your parent and child both contain a constructor(__construct()) method, only the child class constructor will run. There may be occasions where you need to run the parent __construct() method from it's child. If you need to do that, then you will need to...
To support a given application, you often create a new role and database to match. The shell commands to run would be these: $ createuser -P blogger Enter password for the new role: ******** Enter it again: ******** $ createdb -O blogger blogger This assumes that pg_hba.conf has been prope...
If we know the length of the string, we can use a for loop to iterate over its characters: char * string = "hello world"; /* This 11 chars long, excluding the 0-terminator. */ size_t i = 0; for (; i < 11; i++) { printf("%c\n", string[i]); /* Print each character of ...
val emailRegex: Regex = "(.+)@(.+)\\.(.+)".r "[email protected]" match { case emailRegex(userName, domain, topDomain) => println(s"Hi $userName from $domain") case _ => println(s"This is not a valid email.") } In this example, the regex attem...
// *** Find all the objects which is of type movie, Both the syntax are valid *** NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",@1]; // OR //NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",[NSNumbe...
// *** Case Insensitive comparison with exact title match *** NSPredicate *filterByNameCIS = [NSPredicate predicateWithFormat:@"self.title LIKE[cd] %@",@"Tom and Jerry"]; NSLog(@"Filter By Name(CIS) : %@",[array filteredArrayUsingPredicate:filterByNameCIS]);
// *** Case sensitive with exact title match *** NSPredicate *filterByNameCS = [NSPredicate predicateWithFormat:@"self.title = %@",@"Tom and Jerry"]; NSLog(@"Filter By Name(CS) : %@",[array filteredArrayUsingPredicate:filterByNameCS]);
// *** Case Insensitive comparison with matching subset *** NSPredicate *filterByName = [NSPredicate predicateWithFormat:@"self.title CONTAINS[cd] %@",@"Tom"]; NSLog(@"Filter By Containing Name : %@",[array filteredArrayUsingPredicate:filterByName]);
public bool IsTypeNullable<T>() { return Nullable.GetUnderlyingType( typeof(T) )!=null; }
You can use a For Each...Next loop to iterate through any IEnumerable type. This includes arrays, lists, and anything else that may be of type IEnumerable or returns an IEnumerable. An example of looping through a DataTable's Rows property would look like this: For Each row As DataRow In DataTable...
An overload without conversions needed for parameter types or only conversions needed between types that are still considered exact matches is preferred over an overload that requires other conversions in order to call. void f(int x); void f(double x); f(42); // calls f(int) When an argument b...
When an extension method returns a value that has the same type as its this argument, it can be used to "chain" one or more method calls with a compatible signature. This can be useful for sealed and/or primitive types, and allows the creation of so-called "fluent" APIs if the me...
Method chaining is a programming strategy that simplifies your code and beautifies it. Method chaining is done by ensuring that each method on an object returns the entire object, instead of returning a single element of that object. For example: function Door() { this.height = ''; this.w...
Start two named nodes in two terminal windows: >iex --name [email protected] iex([email protected])> >iex --name [email protected] iex([email protected])> Connect two nodes by instructing one node to connect: iex([email protected])> Node.connect :"[email protected]" true The two n...
Start a named process on one IP address: $ iex --name [email protected] --cookie chocolate iex([email protected])> Node.ping :"[email protected]" :pong iex([email protected])> Node.list [:"[email protected]"] Start another named process on a different IP address: $ iex ...
The simple answer is that you cannot do this. Once an array has been created, its size cannot be changed. Instead, an array can only be "resized" by creating a new array with the appropriate size and copying the elements from the existing array to the new one. String[] listOfCities = ne...
When working with regular expressions one modifier for PCRE is g for global match. In R matching and replacement functions have two version: first match and global match: sub(pattern,replacement,text) will replace the first occurrence of pattern by replacement in text gsub(pattern,replace...
When SQL/Plus or SQL Developer display dates they will perform an implicit conversion to a string using the default date format model (see the Setting the Default Date Format Model example). You can change how a date is displayed by changing the NLS_DATE_FORMAT parameter.
set(my_global_string "a string value" CACHE STRING "a description about the string variable") set(my_global_bool TRUE CACHE BOOL "a description on the boolean cache entry") In case a cached variable is already defined in the cache when CMake processes the ...

Page 19 of 109