Tutorial by Examples: c

UNICODE string data types of either fixed length or variable length. Syntax: NCHAR [ ( n_chars ) ] NVARCHAR [ ( n_chars | MAX ) ] Use MAX for very long strings that may exceed 8000 characters.
NSArray *myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; // Convert myColors to mutable NSMutableArray *myColorsMutable = [myColors mutableCopy];
Long vectors with long runs of the same value can be significantly compressed by storing them in their run-length encoding (the value of each run and the number of times that value is repeated). As an example, consider a vector of length 10 million with a huge number of 1's and only a small number o...
In Python 3, many of the dictionary methods are quite different in behaviour from Python 2, and many were removed as well: has_key, iter* and view* are gone. Instead of d.has_key(key), which had been long deprecated, one must now use key in d. In Python 2, dictionary methods keys, values and items ...
quickCheckAll is a Template Haskell helper which finds all the definitions in the current file whose name begins with prop_ and tests them. {-# LANGUAGE TemplateHaskell #-} import Test.QuickCheck (quickCheckAll) import Data.List (sort) idempotent :: Eq a => (a -> a) -> a -> Bool ...
static class Program { static void Main() { dynamic dynamicObject = new ExpandoObject(); string awesomeString = "Awesome"; // Prints True Console.WriteLine(awesomeString.IsThisAwesome()); dynamicObject.StringValue = awesomeStrin...
C++11 One of constraining function is to use trailing decltype to specify the return type: namespace details { using std::to_string; // this one is constrained on being able to call to_string(T) template <class T> auto convert_to_string(T const& val, int ) ->...
main.rs extern crate serde; extern crate serde_json; // Import this crate to derive the Serialize and Deserialize traits. #[macro_use] extern crate serde_derive; #[derive(Serialize, Deserialize, Debug)] struct Point { x: i32, y: i32, } fn main() { let point = Point { x: ...
fn main() { let maybe_cake = Some("Chocolate cake"); let not_cake = None; // The unwrap method retrieves the value from the Option // and panics if the value is None println!("{}", maybe_cake.unwrap()); // The expect method works much like the un...
A React component can be defined as an ES6 class that extends the base React.Component class. In its minimal form, a component must define a render method that specifies how the component renders to the DOM. The render method returns React nodes, which can be defined using JSX syntax as HTML-like ta...
Switch statements compare a single test value to multiple conditions, and performs any associated actions for successful comparisons. It can result in multiple matches/actions. Given the following switch... switch($myValue) { 'First Condition' { 'First Action' } 'Second Condition' ...
The -Regex parameter allows switch statements to perform regular expression matching against conditions. Example: switch -Regex ('Condition') { 'Con\D+ion' {'One or more non-digits'} 'Conditio*$' {'Zero or more "o"'} 'C.ndition' {'Any single char.'} '^C\w+ition$'...
The break keyword can be used in switch statements to exit the statement before evaluating all conditions. Example: switch('Condition') { 'Condition' { 'First Action' } 'Condition' { 'Second Action' break } 'Condition' { 'Third Action' } } Output...
The -Wildcard parameter allows switch statements to perform wildcard matching against conditions. Example: switch -Wildcard ('Condition') { 'Condition' {'Normal match'} 'Condit*' {'Zero or more wildcard chars.'} 'C[aoc]ndit[f-l]on' {'Range and set of chars...
The -Exact parameter enforces switch statements to perform exact, case-insensitive matching against string-conditions. Example: switch -Exact ('Condition') { 'condition' {'First Action'} 'Condition' {'Second Action'} 'conditioN' {'Third Action'} '^*ondition$' {'Fourth Action...
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...
The -file parameter allows the switch statement to receive input from a file. Each line of the file is evaluated by the switch statement. Example file input.txt: condition test Example switch statement: switch -file input.txt { 'condition' {'First Action'} 'test' {'Second Action...
The Default keyword is used to execute an action when no other conditions match the input value. Example: switch('Condition') { 'Skip Condition' { 'First Action' } 'Skip This Condition Too' { 'Second Action' } Default { 'Default Action' } } Output: D...
Fixnum#to_s takes an optional base argument and represents the given number in that base: 2.to_s(2) # => "10" 3.to_s(2) # => "11" 3.to_s(3) # => "10" 10.to_s(16) # => "a" If no argument is provided, then it represents the number in bas...
Compile errors can be generated using the preprocessor. This is useful for a number of reasons some of which include, notifying a user if they are on an unsupported platform or an unsupported compiler. e.g. Return Error if gcc version is 3.0.0 or earlier. #if __GNUC__ < 3 #error "This cod...

Page 87 of 826