Tutorial by Examples

In standard pattern matching, the identifier used will shadow any identifier in the enclosing scope. Sometimes it is necessary to match on the enclosing scope's variable. The following example function takes a character and a list of tuples and returns a new list of tuples. If the character existed...
In order to get const char* access to the data of a std::string you can use the string's c_str() member function. Keep in mind that the pointer is only valid as long as the std::string object is within scope and remains unchanged, that means that only const methods may be called on the object. C++1...
Inheritance works just like it does in other object-oriented languages: methods defined on the superclass are accessible in the extending subclass. If the subclass declares its own constructor then it must invoke the parents constructor via super() before it can access this. class SuperClass { ...
The lambda keyword creates an inline function that contains a single expression. The value of this expression is what the function returns when invoked. Consider the function: def greeting(): return "Hello" which, when called as: print(greeting()) prints: Hello This can ...
This example shows the usage of the ILGenerator by generating code that makes use of already existing and new created members as well as basic Exception handling. The following code emits a DynamicAssembly that contains an equivalent to this c# code: public static class UnixTimeHelper { priva...
Branching in Subversion is very simple. In the simplest form, creating a new branch requires you to run the command against the remote repository's URLs. For example, let's create a new branch out of the mainline trunk: svn copy https://svn.example.com/svn/MyRepo/MyProject/trunk https://svn.example...
When you interact with the remote central repository using your private local workspace -- the working copy -- you can use repository-relative URL instead of direct URL to URL copy to create a new branch: svn copy "^/MyProject/trunk" "^/MyProject/branches/MyNewBranch" -m "C...
The working copy (WC) is your local and private workspace that you use to interact with the central Subversion repository. You use the working copy to modify the contents of your project and fetch changes committed by others. The working copy contains your project's data and looks and acts like a r...
Before publishing a package you have to version it. npm supports semantic versioning, this means there are patch, minor and major releases. For example, if your package is at version 1.2.3 to change version you have to: patch release: npm version patch => 1.2.4 minor release: npm version min...
Delete a file asynchronously: var fs = require('fs'); fs.unlink('/path/to/file.txt', function(err) { if (err) throw err; console.log('file deleted'); }); You can also delete it synchronously*: var fs = require('fs'); fs.unlinkSync('/path/to/file.txt'); console.log('file deleted'...
for (x <- 1 to 10) println("Iteration number " + x) This demonstrates iterating a variable, x, from 1 to 10 and doing something with that value. The return type of this for comprehension is Unit.
This demonstrates a filter on a for-loop, and the use of yield to create a 'sequence comprehension': for ( x <- 1 to 10 if x % 2 == 0) yield x The output for this is: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 4, 6, 8, 10) A for comprehension is useful when you need to crea...
This shows how you can iterate over multiple variables: for { x <- 1 to 2 y <- 'a' to 'd' } println("(" + x + "," + y + ")") (Note that to here is an infix operator method that returns an inclusive range. See the definition here.) This creates the outp...
Consider this simple project with a flat directory structure: example |-- example.asd |-- functions.lisp |-- main.lisp |-- packages.lisp `-- tools.lisp The example.asd file is really just another Lisp file with little more than an ASDF-specific function call. Assuming your project depends o...
Can be used to shorten if/else operations. This comes in handy for returning a value quickly (i.e. in order to assign it to another variable). For example: var animal = 'kitty'; var result = (animal === 'kitty') ? 'cute' : 'still nice'; In this case, result gets the 'cute' value, because the v...
#include <lua.h> #include <lauxlib.h> #include <lualib.h> int main(void) { 5.1 /* Start by creating a new VM state */ lua_State *L = luaL_newstate(); /* Load standard Lua libraries: */ luaL_openlibs(L); 5.1 /* For older version of Lua use lua_open ins...
Generally To use regular expression specific characters (?+| etc.) in their literal meaning they need to be escaped. In common regular expression this is done by a backslash \. However, as it has a special meaning in Java Strings, you have to use a double backslash \\. These two examples will not ...
git cherry-pick <commit-hash> will apply the changes made in an existing commit to another branch, while recording a new commit. Essentially, you can copy commits from branch to branch. Given the following tree (Source) dd2e86 - 946992 - 9143a9 - a6fd86 - 5a6057 [master] \ ...
The background-image property is used to specify a background image to be applied to all matched elements. By default, this image is tiled to cover the entire element, excluding margin. .myClass { background-image: url('/path/to/image.jpg'); } To use multiple images as background-image, defi...
Method Chaining is a technique explained in Martin Fowler's book Domain Specific Languages. Method Chaining is summarized as Makes modifier methods return the host object, so that multiple modifiers can be invoked in a single expression. Consider this non-chaining/regular piece of code (ported...

Page 80 of 1336