Tutorial by Examples: ast

The System.String class supports a number of methods to convert between uppercase and lowercase characters in a string. System.String.ToLowerInvariant is used to return a String object converted to lowercase. System.String.ToUpperInvariant is used to return a String object converted to upper...
%paste This is the primary Magic Method for pasting. It directly pastes text from the system clipboard, intelligently handling common issues with newlines and indentation. %cpaste If you are using IPython via SSH, use %cpaste instead, as it does not need to access the remote system clipbo...
Consider this example function to check if a host is up: is_alive() { ping -c1 "$1" &> /dev/null } This function sends a single ping to the host specified by the first function parameter. The output and error output of ping are both redirected to /dev/null, so the functi...
A Static variable declared locally is not destructed and does not lose its value when the Sub procedure is exited. Subsequent calls to the procedure do not require re-initialization or assignment although you may want to 'zero' any remembered value(s). These are particularly useful when late bindin...
To make long text at most N characters long but leave last word intact, use .{0,N}\b pattern: ^(.{0,N})\b.*
UISplitViewController must be the rootViewController of your application. AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] i...
The example Checking a string for unwanted characters, describes how to test and reject strings that don't meet certain criteria. Obviously, rejecting input outright is not always possible, and sometimes you just have to make do with what you receive. In these cases, a cautious developer will attemp...
UISplitViewController needs to the root view controller of your app’s window AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] self.window.ba...
Raycasting means throwing a ray from the mouse position on the screen to the scene, this is how threejs determines what object you want to click on if you have implemented it. Threejs gets that information using an octree, but still in production you may not want to compute the result at each frame ...
Traditional way interface MathOperation{ boolean unaryOperation(int num); } public class LambdaTry { public static void main(String[] args) { MathOperation isEven = new MathOperation() { @Override public boolean unaryOperation(int num) { ...
pop removes the last element from the array. Here is an example : my_array = array('i', [1,2,3,4,5]) my_array.pop() # array('i', [1, 2, 3, 4]) So we see that the last element (5) was popped out of array.
You are able to append a string to a character array using fromstring() my_char_array = array('c', ['g','e','e','k']) my_char_array.fromstring("stuff") print(my_char_array) #array('c', 'geekstuff')
2005 The following iterates over the characters of the string s. It works similarly for looping over the elements of an array or a set, so long as the type of the loop-control variable (c, in this example) matches the element type of the value being iterated. program ForLoopOnString; {$APPTYPE ...
6 This can be done using the .repeat() method: "abc".repeat(3); // Returns "abcabcabc" "abc".repeat(0); // Returns "" "abc".repeat(-1); // Throws a RangeError 6 In the general case, this should be done using a correct polyfill for the ES6...
To split strings, Guava introduces the Splitter class. Why not use Java's splitting capabilities? As a rule, Guava does not duplicate functionality that is readily available in Java. Why then do we need an additional Splitter class? Do the split methods in Java's String class not provide us with a...
If you need to find the last day of the month, you can do complicated DateTime gymnastics or you can use the following method. Say you want to find the last day of February 2021. Do the following: Integer month = 2; Integer day = null; Integer year = 2021; // Create a new DateTime object for ...
If static_cast is used to convert a pointer (resp. reference) to base class to a pointer (resp. reference) to derived class, but the operand does not point (resp. refer) to an object of the derived class type, the behavior is undefined. See Base to derived conversion.
The TIMESTAMP column will show when the row was last updated. CREATE TABLE `TestLastUpdate` ( `ID` INT NULL, `Name` VARCHAR(50) NULL, `Address` VARCHAR(50) NULL, `LastUpdate` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) COMMENT='Last Update' ;
Consider a grid working on some task, e.g. a parallel reduction. Initially, each block can do its work independently, producing some partial result. At the end however, the partial results need to be combined and merged together. A typical example is a reduction algorithm on a big data. A typica...
If a void* value is converted to a pointer to object type, T*, but is not properly aligned for T, the resulting pointer value is unspecified. Example: // Suppose that alignof(int) is 4 int x = 42; void* p1 = &x; // Do some pointer arithmetic... void* p2 = static_cast<char*>(p1) + 2; ...

Page 16 of 26