Tutorial by Examples

NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; or NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", nil]; NSArray *objects = [NSArray arrayWithObjects:@"va...
It is possible to treat a GoogleMap as an Android view if we make use of the provided MapView class. Its usage is very similar to MapFragment. In your layout use MapView as follows: <com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" ...
Prefer public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { if (orderLine == null) throw new ArgumentNullException(nameof(orderLine)); ... } } Over public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { ...
What is Ubuntu Ubuntu is an open source software platform, but colloquially, when Ubuntu is referred to it's mainly toward the Ubuntu operating system. Ubuntu is based on Debian and uses the same package management system (deb and apt). Installation So you want to give Ubuntu a try! That's gr...
You may need to convert a Stream emitting Optional to a Stream of values, emitting only values from existing Optional. (ie: without null value and not dealing with Optional.empty()). Optional<String> op1 = Optional.empty(); Optional<String> op2 = Optional.of("Hello World");...
The function php_sapi_name() and the constant PHP_SAPI both return the type of interface (Server API) that is being used by PHP. They can be used to restrict the execution of a script to the command line, by checking whether the output of the function is equal to cli. if (php_sapi_name() === 'cli')...
A data.table is an enhanced version of the data.frame class from base R. As such, its class() attribute is the vector "data.table" "data.frame" and functions that work on a data.frame will also work with a data.table. There are many ways to create, load or coerce to a data.table....
A class marked with the keyword abstract cannot be instantiated. A class must be marked as abstract if it contains abstract members or if it inherits abstract members that it doesn't implement. A class may be marked as abstract even if no abstract members are involved. Abstract classes are usually...
float float is an alias to the .NET datatype System.Single. It allows IEEE 754 single-precision floating point numbers to be stored. This data type is present in mscorlib.dll which is implicitly referenced by every C# project when you create them. Approximate range: -3.4 × 1038 to 3.4 × 1038 Deci...
An unsigned integer, or uint, is a numeric datatype that only can hold positive integers. Like it's name suggests, it represents an unsigned 32-bit integer. The uint keyword itself is an alias for the Common Type System type System.UInt32. This datatype is present in mscorlib.dll, which is implicitl...
Partial templates (partials) are a way of breaking the rendering process into more manageable chunks. Partials allow you to extract pieces of code from your templates to separate files and also reuse them throughout your templates. To create a partial, create a new file that begins with an undersco...
To let rails automatically and correctly link assets (css/js/images) in most cases you want to use built in helpers. (Official documentation) Image helpers image_path This returns the path to an image asset in app/assets/images. image_path("edit.png") # => /assets/edit.png image_...
A common pattern is to use an inline, or trailing, if or unless: puts "x is less than 5" if x < 5 This is known as a conditional modifier, and is a handy way of adding simple guard code and early returns: def save_to_file(data, filename) raise "no filename given" if fi...
Add/remove fields in existing tables Create a migration by running: rails generate migration AddTitleToCategories title:string This will create a migration that adds a title column to a categories table: class AddTitleToCategories < ActiveRecord::Migration[5.0] def change add_column...
preg_match checks whether a string matches the regular expression. $string = 'This is a string which contains numbers: 12345'; $isMatched = preg_match('%^[a-zA-Z]+: [0-9]+$%', $string); var_dump($isMatched); // bool(true) If you pass in a third parameter, it will be populated with the matchi...
NSString has a length property to get the number of characters. NSString *string = @"example"; NSUInteger length = string.length; // length equals 7 As in the Splitting Example, keep in mind that NSString uses UTF-16 to represent characters. The length is actually just the numbe...
This is the Python 2 syntax, note the commas , on the raise and except lines: Python 2.x2.3 try: raise IOError, "input/output error" except IOError, exc: print exc In Python 3, the , syntax is dropped and replaced by parenthesis and the as keyword: try: raise IOErro...
Rails uses sqlite3 as the default database, but you can generate a new rails application with a database of your choice. Just add the -d option followed by the name of the database. $ rails new MyApp -T -d postgresql This is a (non-exhaustive) list of available database options: mysql oracle...
"string".upcase # => "STRING" "STRING".downcase # => "string" "String".swapcase # => "sTRING" "string".capitalize # => "String" These four methods do not modify the original receiver. For exampl...
Suppose you have a repository structure like this: examples/ output.log src/ <files not shown> output.log README.md output.log in the examples directory is valid and required for the project to gather an understanding while the one beneath src/ is created while debugging a...

Page 108 of 1336