Tutorial by Examples

If the compiler can infer that an object can't be null at a certain point, you don't have to use the special operators anymore: var string: String? = "Hello!" print(string.length) // Compile error if(string != null) { // The compiler now knows that string can't be null print(...
In order to install PostgreSQL on OSX, you need to know which versions are currently supported. Use this command to see what versions you have available. sudo port list | grep "^postgresql[[:digit:]]\{2\}[[:space:]]" You should get a list that looks something like the following: post...
Ruby Standard Library has a Singleton module which implements the Singleton pattern. The first step in creating a Singleton class is to require and include the Singleton module in a class: require 'singleton' class Logger include Singleton end If you try to instantiate this class as you n...
If need set value 0 to column B, where in column A are duplicated data first create mask by Series.duplicated and then use DataFrame.ix or Series.mask: In [224]: df = pd.DataFrame({'A':[1,2,3,3,2], ...: 'B':[1,7,3,0,8]}) In [225]: mask = df.A.duplicated(keep=False) In...
Use drop_duplicates: In [216]: df = pd.DataFrame({'A':[1,2,3,3,2], ...: 'B':[1,7,3,0,8]}) In [217]: df Out[217]: A B 0 1 1 1 2 7 2 3 3 3 3 0 4 2 8 # keep only the last value In [218]: df.drop_duplicates(subset=['A'], keep='last') Out[218]: ...
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...
Running the command: grep sam someFile.txt When someFile.txt contains: fred 14 m foo sam 68 m bar christina 83 f baz bob 22 m qux Sam 41 m quux Will produce this output: sam 68 m bar
class Person { public string FirstName { get; set; } public string LastName { get; set; } } class Pet { public string Name { get; set; } public Person Owner { get; set; } } public static void Main(string[] args) { var magnus = new Person { FirstName = "Magnus...
The unary plus (+) precedes its operand and evaluates to its operand. It attempts to convert the operand to a number, if it isn't already. Syntax: +expression Returns: a Number. Description The unary plus (+) operator is the fastest (and preferred) method of converting something into a n...
The delete operator deletes a property from an object. Syntax: delete object.property delete object['property'] Returns: If deletion is successful, or the property did not exist: true If the property to be deleted is an own non-configurable property (can't be deleted): false in non...
The typeof operator returns the data type of the unevaluated operand as a string. Syntax: typeof operand Returns: These are the possible return values from typeof: TypeReturn valueUndefined"undefined"Null"object"Boolean"boolean"Number"number"String&quot...
The void operator evaluates the given expression and then returns undefined. Syntax: void expression Returns: undefined Description The void operator is often used to obtain the undefined primitive value, by means of writing void 0 or void(0). Note that void is an operator, not a functio...
The unary negation (-) precedes its operand and negates it, after trying to convert it to number. Syntax: -expression Returns: a Number. Description The unary negation (-) can convert the same types / values as the unary plus (+) operator can. Values that can't be converted will evaluat...
The bitwise NOT (~) performs a NOT operation on each bit in a value. Syntax: ~expression Returns: a Number. Description The truth table for the NOT operation is: aNOT a01101337 (base 10) = 0000010100111001 (base 2) ~1337 (base 10) = 1111101011000110 (base 2) = -1338 (base 10) A bit...
The logical NOT (!) operator performs logical negation on an expression. Syntax: !expression Returns: a Boolean. Description The logical NOT (!) operator performs logical negation on an expression. Boolean values simply get inverted: !true === false and !false === true. Non-boolean val...
DynamoDB is a fully managed service provided by AWS. It does not need to be installed or configured. AWS is responsible for all administrative burdens of operating, scalling and backup/restore of the distributed database.
dc is one of the oldest language on Unix. It is using the reverse polish notation, which means that you are first stacking numbers, then operations. For example 1+1 is written as 1 1+. To print an element from the top of the stack use command p echo '2 3 + p' | dc 5 or dc <<< '2 3...
It's often useful to combine multiple plot types in one graph (for example a Barplot next to a Scatterplot.) R makes this easy with the help of the functions par() and layout(). par() par uses the arguments mfrow or mfcol to create a matrix of nrows and ncols c(nrows, ncols) which will serve as a ...
All DATEs have a time component; however, it is customary to store dates which do not need to include time information with the hours/minutes/seconds set to zero (i.e. midnight). Use an ANSI DATE literal (using ISO 8601 Date format): SELECT DATE '2000-01-01' FROM DUAL; Convert it from a string ...
Convert it from a string literal using TO_DATE(): SELECT TO_DATE( '2000-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS' ) FROM DUAL; Or use a TIMESTAMP literal: CREATE TABLE date_table( date_value DATE ); INSERT INTO date_table ( date_value ) VALUES ( TIMESTAMP '2000-01-01 12:00:00' ); Oracl...

Page 257 of 1336