Tutorial by Examples: e

Haxe's enumeration types are algebraic data types (ADT). Their primary use is for describing data structures. Enums are denoted by the enum keyword and contain one or more enum constructors. enum Color { Red; Green; Blue; RGB(r : Int, g : Int, b : Int); } The above enum can ...
Values passed as enum constructor arguments can be captured into variables by use of pattern matching. Assume the following enum: enum Color { RGB(r : Int, g : Int, b : Int); HSV(h : Int, s : Float, v : Float); } The red channel value can be captured as follows: var color = Color.RG...
Enum constructors can be matched using pattern matching. Assume the following enum: enum Color { Red; Green; Blue; RGB(r : Int, g : Int, b : Int); } Colours with only a green channel value can be matched as follows: var color = Color.RGB(0, 127, 0); var isGreenOnly = swit...
Operator overloading is only possible with abstract types. The following abstract defines a Vec2i type based on the Array<Int> type. This is a two-component vector with integer values. Operator overloading is made possible my the @:op compiler metadata. Only the available numeric operators ca...
BackAndroid.addEventListener('hardwareBackPress', function() { if (!this.onMainScreen()) { this.goBack(); return true; } return false; }); Note: this.onMainScreen() and this.goBack() are not built in functions, you also need to implement those. (https://github.c...
To set LFS options that apply to all clones, create and commit a file named .lfsconfig at the repository root. This file can specify LFS options the same way as allowed in .git/config. For example, to exclude a certain file from LFS fetches be default, create and commit .lfsconfig with the followin...
In Groovy, the inject() method is one of the cumulative methods that allows us to add (or inject) new functionality into any object that implements the inject() method. In the case of a Collection, we can apply a closure to a collection of objects uniformly and then collate the results into a single...
Since there is no STRING_SPLIT function we need to use XML hack to split the string into rows: Example: SELECT split.a.value('.', 'VARCHAR(100)') AS Value FROM (SELECT Cast ('<M>' + Replace('A|B|C', '|', '</M><M>')+ '</M>' AS XML) AS Data) AS A CROSS apply data...
Overview These instructions are for acquiring, building, and installing openssl from source. Openssl is usually included in package managers as well. Resources https://github.com/openssl/openssl Dependencies make perl 5 gcc/clang git Dependencies can be installed through a package mana...
Complete the Installation and setup part to connect your app to Firebase. This will create the project in Firebase. Add the dependency for Firebase CrashReporting to your module-level build.gradle file: compile 'com.google.firebase:firebase-crash:9.4.0'
Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions). You can create your custom report using: FirebaseCrash.report(new Exception("My first Android non-fatal error")); You can check in the log when FirebaseCrash initialized the module: ...
public class SoundActivity extends Activity { private MediaPlayer mediaPlayer; ProgressBar progress_bar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tool_sound); ...
Problem: Vim users are not always happy. Solution: Make them happy. 7.4 :smile Note: Requires patch version ≥7.4.1005
To get the the exact size of a UIButton's text based on its font, use the function intrinsicContentSize. Swift button.intrinsicContentSize.width Objective-C button.intrinsicContentSize.width;
NSString provides method boundingRectWithSize which can be used to predict the resulting CGSize of a UILabel based on its text and font without the need of creating a UILabel Objective-C [[text boundingRectWithSize:maxSize options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineF...
SilverStripe has reasonably good support for submitting form data using AJAX requests. Below is example code of how to set up a basic Form that accepts submissions by both AJAX and traditional default browser behaviour (as is good practice). Adding the form to our controller First we need to defin...
The following class is used to demonstrate, how instances of classes can be created: JavaFX 8 The annotation in Person(@NamedArg("name") String name) has to be removed, since the @NamedArg annotation is unavailable. package fxml.sample; import javafx.beans.NamedArg; import javafx....
public String getAppVersion() throws PackageManager.NameNotFoundException { PackageManager manager = getApplicationContext().getPackageManager(); PackageInfo info = manager.getPackageInfo( getApplicationContext().getPackageName(), ...
You should use this when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with _confirmation appended. ...
When using Autolayout with a UIScrollView, it does NOT resize properly depending on the size of its contents or subviews. In order to get a UIScrollView to automatically scroll when its contents become too large to fit in the visible area, we need to add a ContentView and some constraints that allo...

Page 563 of 1191