Tutorial by Examples

Use .slice() to extract substrings given two indices: var s = "0123456789abcdefg"; s.slice(0, 5); // "01234" s.slice(5, 6); // "5" Given one index, it will take from that index to the end of the string: s.slice(10); // "abcdefg"
Use .split to go from strings to an array of the split substrings: var s = "one, two, three, four, five" s.split(", "); // ["one", "two", "three", "four", "five"] Use the array method .join to go back to a string: s.split(&...
All JavaScript strings are unicode! var s = "some ∆≈ƒ unicode ¡™£¢¢¢"; s.charCodeAt(5); // 8710 There are no raw byte or binary strings in JavaScript. To effectively handle binary data, use Typed Arrays.
To detect whether a parameter is a primitive string, use typeof: var aString = "my string"; var anInt = 5; var anObj = {}; typeof aString === "string"; // true typeof anInt === "string"; // false typeof anObj === "string"; // false If you ev...
Flask lets you use templates for dynamic web page content. An example project structure for using templates is as follows: myproject/ /app/ /templates/ /index.html /views.py views.py: from flask import Flask, render_template app = Flask(__name__) @app...
This demonstrates how to print each element of a Map val map = Map(1 -> "a", 2 -> "b") for (number <- map) println(number) // prints (1,a), (2,b) for ((key, value) <- map) println(value) // prints a, b This demonstrates how to print each element of a list val l...
Full example code included at the end Windows components for OpenGL WGL WGL (can be pronounced wiggle) stands for "Windows-GL", as in "an interface between Windows and OpenGL" - a set of functions from the Windows API to communicate with OpenGL. WGL functions have a wgl prefix...
var MyDict = new Dictionary<string,T>(StringComparison.InvariantCultureIgnoreCase)
The Scala compiler will automatically convert methods into function values for the purpose of passing them into higher-order functions. object MyObject { def mapMethod(input: Int): String = { int.toString } } Seq(1, 2, 3).map(MyObject.mapMethod) // Seq("1", "2", &...
using System.Runtime.InteropServices; class PInvokeExample { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern uint MessageBox(IntPtr hWnd, String text, String caption, int options); public static void test() { MessageBox(IntPtr.Zero,...
Use pinvoke.net. Before declaring an extern Windows API function in your code, consider looking for it on pinvoke.net. They most likely already have a suitable declaration with all supporting types and good examples.
Arrays of simple type [DllImport("Example.dll")] static extern void SetArray( [MarshalAs(UnmanagedType.LPArray, SizeConst = 128)] byte[] data); Arrays of string [DllImport("Example.dll")] static extern void SetStrArray(string[] textLines);
If you want to check that a string contains only a certain set of characters, in this case a-z, A-Z and 0-9, you can do so like this, import re def is_allowed(string): characherRegex = re.compile(r'[^a-zA-Z0-9.]') string = characherRegex.search(string) return not bool(string) ...
Any text following a " character on the same line is commented out: DATA ls_booking TYPE flightb. " Commented text
The * character comments out an entire line. The * must be the first character in the line. * DATA ls_booking TYPE flightb. Nothing on this line will be executed.
Detailed instructions on getting domain-driven-design set up or installed.
In certain situations, data declarations can be performed inline. LOOP AT lt_sflight INTO DATA(ls_sflight). WRITE ls_sflight-carrid. ENDLOOP.
DATA begda TYPE sy-datum.
DATA: begda TYPE sy-datum, endda TYPE sy-datum.
A Map is a basic mapping of keys to values. Maps are different from objects in that their keys can be anything (primitive values as well as objects), not just strings and symbols. Iteration over Maps is also always done in the order the items were inserted into the Map, whereas the order is undefine...

Page 200 of 1336