Tutorial by Examples: ti

[1, 2, [[3, 4], [5]], 6].flatten # => [1, 2, 3, 4, 5, 6] If you have a multi-dimensional array and you need to make it a simple (i.e. one-dimensional) array, you can use the #flatten method.
Standard enumerations allow users to declare a useful name for a set of integers. The names are collectively referred to as enumerators. An enumeration and its associated enumerators are defined as follows: enum myEnum { enumName1, enumName2, }; An enumeration is a type, one which is...
A common use for enumerators is for switch statements and so they commonly appear in state machines. In fact a useful feature of switch statements with enumerations is that if no default statement is included for the switch, and not all values of the enum have been utilized, the compiler will issue ...
Enums in Swift are much more powerful than some of their counterparts in other languages, such as C. They share many features with classes and structs, such as defining initialisers, computed properties, instance methods, protocol conformances and extensions. protocol ChangesDirection { mutati...
Detailed instructions on getting date set up or installed.
package { import flash.events.TimerEvent; import flash.utils.Timer; public class CountdownTimer extends Timer { public var time:Number = 0; public function CountdownTimer(time:Number = Number.NEGATIVE_INFINITY, delay:Number = 1000) { super(delay, repeatCount); ...
Using functions that take in and execute closures can be extremely useful for sending a block of code to be executed elsewhere. We can start by allowing our function to take in an optional closure that will (in this case) return Void. func closedFunc(block: (()->Void)? = nil) { print("...
Note: Everything below applies to the str.format method, as well as the format function. In the text below, the two are interchangeable. For every value which is passed to the format function, Python looks for a __format__ method for that argument. Your own custom class can therefore have th...
Select the .xcdatamodeld file. You will notice you have no entities. You will have to create one yourself. At the bottom of Xcode you will notice a button that says "Add Entity" click it and you will have a new entity for you to work with on the project. In this step there are ...
We define the type of boolean expressions whose atoms are identified by strings as type expr = | Atom of string | Not of expr | And of expr * expr | Or of expr * expr and can evaluate these expressions using an oracle : string -> bool giving the values of the atoms we find as follows: le...
Pattern matching allows to deconstruct complex values and it is by no way limited to the “outer most” level of the representation of a value. To illustrate this, we implement the function transforming a boolean expression into a boolean expression where all negations are only on atoms, the so calle...
There are several additional attributes that the Volley NetworkImageView adds to the standard ImageView. However, these attributes can only be set in code. The following is an example of how to make an extension class that will pick up the attributes from your XML layout file and apply them to the N...
A reference to an option &Option<T> cannot be unwrapped if the type T is not copyable. The solution is to change the option to &Option<&T> using as_ref(). Rust forbids transferring of ownership of objects while the objects are borrowed. When the Option itself is borrowed (&a...
Woocommerce is a plugin for WordPress and can be installed like any other WordPress plugin. WooCommerce can only be installed on self hosted installations of WordPress, it cannot be installed onto a site hosted by the wordpress.com service. If you don't have WordPress installed for your website, fo...
Type casting is done with either the as operator: var chair:Chair = furniture as Chair; Or by wrapping the value in Type(): var chair:Chair = Chair(furniture); If the cast fails with as, the result of that cast is null. If the cast fails by wrapping in Type(), a TypeError is thrown.
Functions are of the type Function: function example():void { } trace(example is Function); // true They can be referenced by other variables with the type Function: var ref:Function = example; ref(); // ref.call(), ref.apply(), etc. And they can be passed in as arguments for parameters wh...
You can tell the compiler the type of a value by annotating it with :Type: var value:int = 10; // A property "value" of type "int". Function parameters and return types can also be annotated: // This function accepts two ints and returns an int. function sum(a:int, b:int):i...
The C++ approach - new and delete In a language like C++, the application program is responsible for managing the memory used by dynamically allocated memory. When an object is created in the C++ heap using the new operator, there needs to be a corresponding use of the delete operator to dispose o...
Detailed instructions on getting monogame set up or installed.
3 You can use rem defined by the font-size of your html tag to style elements by setting their font-size to a value of rem and use em inside the element to create elements that scale with your global font-size. HTML: <input type="button" value="Button"> <input type=...

Page 139 of 505