Tutorial by Examples

Array.prototype.map(): Returns a new array with the results of calling a provided function on every element in the original array. The following code example takes an array of persons and creates a new array containing persons with a 'fullName' property var personsArray = [ { id: 1, f...
In JavaScript all arguments are passed by value. When a function assigns a new value to an argument variable, that change will not be visible to the caller: var obj = {a: 2}; function myfunc(arg){ arg = {a: 5}; // Note the assignment is to the parameter variable itself } myfunc(obj); conso...
Information Inheritance allows you to derive a new class from an existing class. You do this using the INHERITING FROM addition in the CLASS subclass DEFINITION INHERITING FROM superclass. statement. The new class subclass inherits all of the components of the existing class superclass. The n...
Information The ABSTRACT and FINAL additions to the METHODS and CLASS statements allow you to define abstract and final methods or classes. An abstract method is defined in an abstract class and cannot be implemented in that class. Instead, it is implemented in a subclass of the class. Abstra...
During development, when certain code paths must be prevented from the reach of control flow, you may use assert(0) to indicate that such a condition is erroneous: switch (color) { case COLOR_RED: case COLOR_GREEN: case COLOR_BLUE: break; default: assert(0); ...
A trick exists that can display an error message along with an assertion. Normally, you would write code like this void f(void *p) { assert(p != NULL); /* more code */ } If the assertion failed, an error message would resemble Assertion failed: p != NULL, file main.c, line 5 Ho...
#define NOTE_C4 262 //From pitches.h file defined in [Arduino Tone Tutorial][1] int Key = 2; int KeyVal = 0; byte speaker = 12; void setup() { pinMode(Key, INPUT); //Declare our key (button) as input pinMode(speaker, OUTPUT); } void loop() { KeyVal = digitalRead(Key); i...
string outsidetext = "I am outside of bracket"; string.Format("{{I am in brackets!}} {0}", outsidetext); //Outputs "{I am in brackets!} I am outside of bracket"
Example : CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = 5; E.g. In the above example code above, location changes of less than 5 m...
Firstly, include the ngStorage source in your index.html. An example injecting ngStorage src would be: <head> <title>Angular JS ngStorage</title> <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> &l...
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...
List<T> is a list of a given type. Items can be added, inserted, removed and addressed by index. using System.Collections.Generic; var list = new List<int>() { 1, 2, 3, 4, 5 }; list.Add(6); Console.WriteLine(list.Count); // 6 list.RemoveAt(3); Console.WriteLine(list.Count); // 5 ...
Linux kernel source code can be found in https://www.kernel.org/ Download extract and enter to the kernel directory Type these commands step by steps in your terminal.(Choose the appropriate version you needed instead of linux-4.7.tar.gz ) wget http://www.kernel.org/pub/linux/kernel/v4.7/linux-4....
IronPython is completly written using managed .net (c#) code. So all builtin python methods and libraries (such as next(), int(), etc.) are writtin in .net. This example shows the implementation of len() for a list of different types (only a few): .... public static int len([NotNull]List/*!*/ l...
index.html <html> <head> <title>Angular-UI Router Example</title> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.9/angular.js"></script> <script type="text/java...
begin returns an iterator to the first element in the sequence container. end returns an iterator to the first element past the end. If the vector object is const, both begin and end return a const_iterator. If you want a const_iterator to be returned even if your vector is not const, you can use ...
An iterator to the first element in the container. If a map object is const-qualified, the function returns a const_iterator. Otherwise, it returns an iterator. // Create a map and insert some values std::map<char,int> mymap; mymap['b'] = 100; mymap['a'] = 200; mymap['c'] = 300; // It...
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...
Declaration and usage. // a is const int, so it can't be changed const int a = 15; a = 12; // Error: can't assign new value to const variable a += 1; // Error: can't assign new value to const variable Binding of references and pointers int &b = a; // Error: ca...
int a = 0, b = 2; const int* pA = &a; // pointer-to-const. `a` can't be changed through this int* const pB = &a; // const pointer. `a` can be changed, but this pointer can't. const int* const pC = &a; // const pointer-to-const. //Error: Cannot assign to a const reference *pA = b...

Page 296 of 1336