Tutorial by Examples

// Create an array with a fixed size and type. var array = new Uint8Array(5); // Generate cryptographically random values crypto.getRandomValues(array); // Print the array to the console console.log(array); crypto.getRandomValues(array) can be used with instances of the following classes...
// Convert string to ArrayBuffer. This step is only necessary if you wish to hash a string, not if you aready got an ArrayBuffer such as an Uint8Array. var input = new TextEncoder('utf-8').encode('Hello world!'); // Calculate the SHA-256 digest crypto.subtle.digest('SHA-256', input) // Wait fo...
With constructor: Vector v1 = new Vector(); v1.X = 1; v1.Y = 2; v1.Z = 3; Console.WriteLine("X = {0}, Y = {1}, Z = {2}",v1.X,v1.Y,v1.Z); // Output X=1,Y=2,Z=3 Vector v1 = new Vector(); //v1.X is not assigned v1.Y = 2; v1.Z = 3; Console.WriteLine("X = {0}, Y = {1}, Z =...
Setting values Using Unicode directly var str: String = "I want to visit 北京, Москва, मुंबई, القاهرة, and 서울시. 😊" var character: Character = "🌍" Using hexadecimal values var str: String = "\u{61}\u{5927}\u{1F34E}\u{3C0}" // a大🍎π var character: Character = &quo...
Swift's C interoperability allows you to use functions and types from the C standard library. On Linux, the C standard library is exposed via the Glibc module; on Apple platforms it's called Darwin. #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Darwin #elseif os(Linux) import Glibc...
6 var myIterableObject = {}; // An Iterable object must define a method located at the Symbol.iterator key: myIterableObject[Symbol.iterator] = function () { // The iterator should return an Iterator object return { // The Iterator object must implement a method, next() next: func...
dynamic foo = 123; Console.WriteLine(foo + 234); // 357 Console.WriteLine(foo.ToUpper()) // RuntimeBinderException, since int doesn't have a ToUpper method foo = "123"; Console.WriteLine(foo + 234); // 123234 Console.WriteLine(foo.ToUpper()): // NOW A STRING
using System; public static void Main() { var value = GetValue(); Console.WriteLine(value); // dynamics are useful! } private static dynamic GetValue() { return "dynamics are useful!"; }
using System; using System.Dynamic; dynamic info = new ExpandoObject(); info.Id = 123; info.Another = 456; Console.WriteLine(info.Another); // 456 Console.WriteLine(info.DoesntExist); // Throws RuntimeBinderException
You can use a colon and the standard numeric format syntax to control how numbers are formatted. var decimalValue = 120.5; var asCurrency = $"It costs {decimalValue:C}"; // String value is "It costs $120.50" (depending on your local currency settings) var withThreeDecimal...
Expressions in C++ are assigned a particular value category, based on the result of those expressions. Value categories for expressions can affect C++ function overload resolution. Value categories determines two important-but-separate properties about an expression. One property is whether the exp...
A prvalue (pure-rvalue) expression is an expression which lacks identity, whose evaluation is typically used to initialize an object, and which can be implicitly moved from. These include, but are not limited to: Expressions that represent temporary objects, such as std::string("123"). ...
An xvalue (eXpiring value) expression is an expression which has identity and represents an object which can be implicitly moved from. The general idea with xvalue expressions is that the object they represent is going to be destroyed soon (hence the "eXpiring" part), and therefore implici...
An lvalue expression is an expression which has identity, but cannot be implicitly moved from. Among these are expressions that consist of a variable name, function name, expressions that are built-in dereference operator uses and expressions that refer to lvalue references. The typical lvalue is s...
A glvalue (a "generalized lvalue") expression is any expression which has identity, regardless of whether it can be moved from or not. This category includes lvalues (expressions that have identity but can't be moved from) and xvalues (expressions that have identity, and can be moved from)...
An rvalue expression is any expression which can be implicitly moved from, regardless of whether it has identity. More precisely, rvalue expressions may be used as the argument to a function that takes a parameter of type T && (where T is the type of expr). Only rvalue expressions may be gi...
Background TypeScript is a typed superset of JavaScript that compiles directly to JavaScript code. TypeScript files commonly use the .ts extension. Many IDEs support TypeScript without any other setup required, but TypeScript can also be compiled with the TypeScript Node.JS package from the command...
You can see what "hunks" of work would be staged for commit using the patch flag: git add -p or git add --patch This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not. Stage this hunk [y,n,q,a,d,/,s,e,?]? ...
In this example, we illustrate string manipulation in MATLAB MEX. We will create a MEX-function that accepts a string as input from MATLAB, copy the data into C-string, modify it and convert it back to mxArray returned to the MATLAB side. The main objective of this example is to show how strings ca...
Since anonymous types are not named, variables of those types must be implicitly typed (var). var anon = new { Foo = 1, Bar = 2 }; // anon.Foo == 1 // anon.Bar == 2 If the member names are not specified, they are set to the name of the property/variable used to initialize the object. int foo ...

Page 98 of 1336