Tutorial by Examples

int [] arr = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; for(int value : arr) { System.out.print(value); System.out.print("\n"); } *Note that the Java foreach is just a for loop with different syntax. Some languages do this and some such as C# use foreach.
int sumArrayRecursive(int * arr, int index, int arraySize) { if (index == (arraySize - 1)) { return arr[index]; } return arr[index] + sumArrayRecursive(arr, index + 1, arraySize); }
var numbers = [1,2,3,4,5]; var squares = numbers.map(function(x) { return x*x; }); // squares is [1,4,9,16,25]
var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce((prev, curr) => prev + curr); console.log(sum); // Output: 15 You can also specify an initial value var arr = [1, 2, 3, 4, 5]; var sum = arr.reduce(function (previousValue, currentValue, currentIndex, array) { return previousValue + cur...
PHP is a weakly-typed language. It does not require explicit declaration of data types. The context in which the variable is used determines its data type; conversion is done automatically: $a = "2"; // string $a = $a + 2; // integer (4) $a = $a + 0.5; // ...
Install node modules npm install express npm install socket.io Node.js server const express = require('express'); const app = express(); const server = app.listen(3000,console.log("Socket.io Hello World server started!")); const io = require('socket.io')(server); io.on('connec...
Although this works only for WebKit based browsers, this is helpful: /* ----------- Non-Retina Screens ----------- */ @media screen and (min-width: 1200px) and (max-width: 1600px) and (-webkit-min-device-pixel-ratio: 1) { } /* ----------- Retina Screens ----------- */ @media scre...
When an object is exposed to the template context, its arguments-less methods are available. This is useful when these functions are "getters". But it can be hazardeous if these methods alter some data or have some side effects. Eventhough you likely trust the template writer, he may not b...
Classes have a local scope during definition, but functions inside the class do not use that scope when looking up names. Because lambdas are functions, and comprehensions are implemented using function scope, this can lead to some surprising behavior. a = 'global' class Fred: a = 'class' ...
$> pwd /home/myUserHome $> cd .. $> pwd /home will print the current path to the console.
Basic assembly support with gcc has the following syntax: asm [ volatile ] ( AssemblerInstructions ) where AssemblerInstructions is the direct assembly code for the given processor. The volatile keyword is optional and has no effect as gcc does not optimize code within a basic asm statement. A...
Extended asm support in gcc has the following syntax: asm [volatile] ( AssemblerTemplate : OutputOperands [ : InputOperands [ : Clobbers ] ]) asm [volatile] goto ( AssemblerTemplate : : Inp...
This attribute is used to give a name to this particular assembly. [assembly: AssemblyTitle("MyProduct")]
This attribute is used to describe the product that this particular assembly is for. Multiple assemblies can be components of the same product, in which case they can all share the same value for this attribute. [assembly: AssemblyProduct("MyProduct")]
When working with large files, you can use the System.IO.File.ReadLines method to read all lines from a file into an IEnumerable<string>. This is similar to System.IO.File.ReadAllLines, except that it doesn't load the whole file into memory at once, making it more efficient when working with l...
File static class By using Create method of the File static class we can create files. Method creates the file at the given path, at the same time it opens the file and gives us the FileStream of the file. Make sure you close the file after you are done with it. ex1: var fileStream1 = File.Create...
File static class File static class can be easily used for this purpose. File.Copy(@"sourcePath\abc.txt", @"destinationPath\abc.txt"); File.Copy(@"sourcePath\abc.txt", @"destinationPath\xyz.txt"); Remark: By this method, file is copied, meaning that it w...
File static class File static class can easily be used for this purpose. File.Move(@"sourcePath\abc.txt", @"destinationPath\xyz.txt"); Remark1: Only changes the index of the file (if the file is moved in the same volume). This operation does not take relative time to the fil...
Ada 2012(TC-1) with Ada.Text_IO; procedure Main is type Some_Float digits 8 range 0.0 .. 10.0; X : Some_Float := 2.71; begin Ada.Text_IO.Put_Line (X'Image); end Main; Result 2.71000E+00
Ada 2012(TC-1) with Ada.Text_IO; procedure Main is type Some_Integer is range -42 .. 42; X : Some_Integer := 17; begin Ada.Text_IO.Put_Line (X'Image); end Main; Result 17

Page 576 of 1336