Tutorial by Examples: case

The -CaseSensitive parameter enforces switch statements to perform exact, case-sensitive matching against conditions. Example: switch -CaseSensitive ('Condition') { 'condition' {'First Action'} 'Condition' {'Second Action'} 'conditioN' {'Third Action'} } Output: Second Act...
One feature provided for free by case classes is an auto-generated equals method that checks the value equality of all individual member fields instead of just checking the reference equality of the objects. With ordinary classes: class Foo(val i: Int) val a = new Foo(3) val b = new Foo(3) prin...
An alternative to extending Enumeration is using sealed case objects: sealed trait WeekDay object WeekDay { case object Mon extends WeekDay case object Tue extends WeekDay case object Wed extends WeekDay case object Thu extends WeekDay case object Fri extends WeekDay case objec...
var MyDict = new Dictionary<string,T>(StringComparison.InvariantCultureIgnoreCase)
String.prototype.toUpperCase(): console.log('qwerty'.toUpperCase()); // 'QWERTY'
String.prototype.toLowerCase() console.log('QWERTY'.toLowerCase()); // 'qwerty'
In normal mode: ~ inverts the case of the character under the cursor, gu{motion} lowercases the text covered by {motion}, gU{motion} uppercases the text covered by {motion} Example (^ marks the cursor position): Lorem ipsum dolor sit amet. ^ Lorem ipSum dolor sit amet. ~ Lorem...
A select case construct conditionally executes one block of constructs or statements depending on the value of a scalar expression in a select case statement. This control construct can be considered as a replacement for computed goto. [name:] SELECT CASE (expr) [CASE (case-value [, case-value] .....
A syntactic extension that lets you write \case in place of \arg -> case arg of. Consider the following function definition: dayOfTheWeek :: Int -> String dayOfTheWeek 0 = "Sunday" dayOfTheWeek 1 = "Monday" dayOfTheWeek 2 = "Tuesday" dayOfTheWeek 3 = "W...
Select Case can be used when many different conditions are possible. The conditions are checked from top to bottom and only the first case that match will be executed. Sub TestCase() Dim MyVar As String Select Case MyVar 'We Select the Variable MyVar to Work with Case "...
Uppercase and lowercase letters of the alphabet are equivalent in the Fortran character set. In other words, Fortran is case insensitive. This behavior is in contrast with case-sensitive languages, such as C++ and many others. As a consequence, the variables a and A are the same variable. In princ...
// *** 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]);
case {1, 2} do {3, 4} -> "This clause won't match." {1, x} -> "This clause will match and bind x to 2 in this clause." _ -> "This clause would match any value." end case is only used to match the given pattern of the particular data...
A single case discriminated union is like any other discriminated union except that it only has one case. // Define single-case discriminated union type. type OrderId = OrderId of int // Construct OrderId type. let order = OrderId 123 // Deconstruct using pattern matching. // Parentheses used...
Incorrect usage: In the following snippet, the last match will never be used: let x = 4 match x with | 1 -> printfn "x is 1" | _ -> printfn "x is anything that wasn't listed above" | 4 -> printfn "x is 4" prints x is anything that wasn't listed abov...
The function toupper will convert a string to upper case (capital letters). For example: BEGIN { greeting = "hello" loud_greeting = toupper(greeting) print loud_greeting } This code will output "HELLO" when run.
Sometimes it is useful to create union types with only one case to implement record-like types: type Point = Point of float * float let point1 = Point(0.0, 3.0) let point2 = Point(-2.5, -4.0) These become very useful because they can be decomposed via pattern matching in the same way as tu...
In comparison to regular classes – case classes notation provides several benefits: All constructor arguments are public and can be accessed on initialized objects (normally this is not the case, as demonstrated here): case class Dog1(age: Int) val x = Dog1(18) println(x.age) // 18 (success!...

Page 2 of 8