Tutorial by Examples: and

The main difference is that double-quoted String literals support string interpolations and the full set of escape sequences. For instance, they can include arbitrary Ruby expressions via interpolation: # Single-quoted strings don't support interpolation puts 'Now is #{Time.now}' # Now is #{Time...
In Python 2, range function returns a list while xrange creates a special xrange object, which is an immutable sequence, which unlike other built-in sequence types, doesn't support slicing and has neither index nor count methods: Python 2.x2.3 print(range(1, 10)) # Out: [1, 2, 3, 4, 5, 6, 7, 8, 9...
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) { ...
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')...
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...
Special care needs to be taken when there is a possibility that an array become an empty array when it comes to logical operators. It is often expected that if all(A) is true then any(A) must be true and if any(A) is false, all(A) must also be false. That is not the case in MATLAB with empty arrays....
First, some terminology: argument (actual parameter): the actual variable being passed to a function; parameter (formal parameter): the receiving variable that is used in a function. In Python, arguments are passed by assignment (as opposed to other languages, where arguments can be passed by...
virtualenv is a tool to build isolated Python environments. This program creates a folder which contains all the necessary executables to use the packages that a Python project would need. Installing the virtualenv tool This is only required once. The virtualenv program may be available through yo...
A module is a file containing Python definitions and statements. Function is a piece of code which execute some logic. >>> pow(2,3) #8 To check the built in function in python we can use dir(). If called without an argument, return the names in the current scope. Else, return an alph...
NSDictionary *inventory = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:13], @"Mercedes-Benz SLK250", [NSNumber numberWithInt:22], @"Mercedes-Benz E350", [NSNumber numberWithInt:19], @"BMW M3 Coupe", [NSNumber numberWithInt:16],...
If a code module does not contain Option Explicit at the top of the module, then the compiler will automatically (that is, "implicitly") create variables for you when you use them. They will default to variable type Variant. Public Sub ExampleDeclaration() someVariable = 10 ...
There are several ways to go about installing matplotlib, some of which will depend on the system you are using. If you are lucky, you will be able to use a package manager to easily install the matplotlib module and its dependencies. Windows On Windows machines you can try to use the pip package ...
Java provides, as part of the utils package, a basic pseudo-random number generator, appropriately named Random. This object can be used to generate a pseudo-random value as any of the built-in numerical datatypes (int, float, etc). You can also use it to generate a random Boolean value, or a random...
The method nextInt(int bound) of Random accepts an upper exclusive boundary, i.e. a number that the returned random value must be less than. However, only the nextInt method accepts a bound; nextLong, nextDouble etc. do not. Random random = new Random(); random.nextInt(1000); // 0 - 999 int num...
First of all, implement your view holder: implements View.OnClickListener, View.OnLongClickListener Then, register the listeners as follows: itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); Next, override the listeners as follows: @Override public void onClick(Vie...
Properties are members of an object. Each named property is a pair of (name, descriptor). The name is a string that allows access (using the dot notation object.propertyName or the square brackets notation object['propertyName']). The descriptor is a record of fields defining the bevahiour of the pr...
// decode NSString *string = [[NSString alloc] initWithData:utf8Data encoding:NSUTF8StringEncoding]; // encode NSData *utf8Data = [string dataUsingEncoding:NSUTF8StringEncoding]; Some supported encodings are: NSASCIIStringEncoding NSUTF8StringEnc...
Download Qt for Linux Open Source Version Go to https://www.qt.io/download-open-source/ and click on Download Now, make sure that you are downloading the Qt installer for Linux. A file with the name qt-unified-linux-x-online.run will be downloaded, then add exec permission chmod +x qt-unified-...
All Java exceptions are instances of classes in the Exception class hierarchy. This can be represented as follows: java.lang.Throwable - This is the base class for all exception classes. Its methods and constructors implement a range of functionality common to all exceptions. java.lang.Excep...

Page 14 of 153