Tutorial by Examples: f

The friend keyword is used to give other classes and functions access to private and protected members of the class, even through they are defined outside the class`s scope. class Animal{ private: double weight; double height; public: friend void printWeight(Animal animal); fr...
Any permission required by your application to access a protected part of the API or to interact with other applications must be declared in your AndroidManifest.xml file. This is done using the <uses-permission /> tag. Syntax <uses-permission android:name="string" android...
// Instantiate Gift Card Model $gift_card = Mage::getModel('enterprise_giftcardaccount/giftcardaccount'); // Populate Gift Card values $gift_card // Your redeemable code, doesn't have to be in this format. ->setCode('2i2j2j-24k1ii1-67774k-231l') // Also has STATUS_DISABLED ...
The = operator is used for assignment. The == operator is used for comparison. One should be careful not to mix the two. Sometimes one mistakenly writes /* assign y to x */ if (x = y) { /* logic */ } when what was really wanted is: /* compare if x is equal to y */ if (x == y) { ...
Be careful with semicolons. Following example if (x > a); a = x; actually means: if (x > a) {} a = x; which means x will be assigned to a in any case, which might not be what you wanted originally. Sometimes, missing a semicolon will also cause an unnoticeable problem: if (i &lt...
Collection initialization syntax can be used when instantiating any class which implements IEnumerable and has a method named Add which takes a single parameter. In previous versions, this Add method had to be an instance method on the class being initialized. In C#6, it can also be an extension me...
Life-cycle hooks are also exposed as DSL elements, where later invocations of the methods shown below will replace the contents of the respective hooks: val a = actor(new Act { whenStarting { testActor ! "started" } whenStopping { testActor ! "stopped" } }) The above i...
Angular supports three types of expressions in the ng-class directive. 1. String <span ng-class="MyClass">Sample Text</span> Specifying an expression that evaluates to a string tells Angular to treat it as a $scope variable. Angular will check the $scope and look for a va...
The goal with using anonymous structs is to decode only the information we care about without littering our app with types that are used only in a single function. jsonBlob := []byte(` { "_total": 1, "_links": { "self": "https://api.twitch.tv/k...
Sometimes you may want to have a lambda expression implementing more than one interface. This is mostly useful with marker interfaces (such as java.io.Serializable) since they don't add abstract methods. For example, you want to create a TreeSet with a custom Comparator and then serialize it and se...
final in Java can refer to variables, methods and classes. There are three simple rules: final variable cannot be reassigned final method cannot be overriden final class cannot be extended Usages Good Programming Practice Some developer consider it good practice to mark a variable final wh...
To obtain a reference to a KClass object representing some class use double colons: val c1 = String::class val c2 = MyClass::class
Functions are first-class citizens in Kotlin. You can obtain a reference on it using double colons and then pass it to another function: fun isPositive(x: Int) = x > 0 val numbers = listOf(-2, -1, 0, 1, 2) println(numbers.filter(::isPositive)) // [1, 2]
To obtain a Java's Class object from Kotlin's KClass use the .java extension property: val stringKClass: KClass<String> = String::class val c1: Class<String> = stringKClass.java val c2: Class<MyClass> = MyClass::class.java The latter example will be optimized by the compile...
Given that the 8086/8088 was used in the IBM PC, and the Operating System on that was most often from Microsoft, Microsoft's assembler MASM was the de facto standard for many years. It followed Intel's syntax closely, but permitted some convenient but "loose" syntax that (in hindsight) onl...
Suppose that you have a pointer to an object of a polymorphic class: Shape *ps; // see example on defining a polymorphic class ps = get_a_new_random_shape(); // if you don't have such a function yet, you // could just write ps = new Square...
Function is a set of instructions, which are grouped together. These grouped instructions together perform certain task. In erlang, all the functions will return a value when they are called. Below is an example of a function that adds two numbers add(X, Y)-> X + Y. This function performs an...
Save with default parameters: df.to_csv(file_name) Write specific columns: df.to_csv(file_name, columns =['col']) Difault delimiter is ',' - to change it: df.to_csv(file_name,sep="|") Write without the header: df.to_csv(file_name, header=False) Write with a given head...
In order to get a view to slowly fade in or out of view, use an ObjectAnimator. As seen in the code below, set a duration using .setDuration(millis) where the millis parameter is the duration (in milliseconds) of the animation. In the below code, the views will fade in / out over 500 milliseconds, o...
Simple form using one variable: for i := 0; i < 10; i++ { fmt.Print(i, " ") } Using two variables (or more): for i, j := 0, 0; i < 5 && j < 10; i, j = i+1, j+2 { fmt.Println(i, j) } Without using initialization statement: i := 0 for ; i < 10; i++ {...

Page 97 of 457