Tutorial by Examples

In Elixir, a common practice is to use anonymous functions. Creating an anonymous function is simple: iex(1)> my_func = fn x -> x * 2 end #Function<6.52032458/1 in :erl_eval.expr/5> The general syntax is: fn args -> output end For readability, you may put parenthesis around t...
create table empl ( name text primary key, boss text null references name on update cascade on delete cascade default null ); insert into empl values ('Paul',null); insert into empl values ('Luke','Paul'); insert into empl values ('Kate'...
The REPLICATE function concatenates a string with itself a specified number of times. Syntax is: REPLICATE ( string-expression , integer ) SELECT REPLICATE ('Hello',4) --returns 'HelloHelloHelloHello'
Public Module Usage Public Sub LikeThis() Dim iCount As Integer Dim sCount As String iCount = 245 sCount = iCount.PadLeft(4, "0") Console.WriteLine(sCount) Console.ReadKey() End Sub End Module Public Module Padding <Extension> Pub...
A metatable defines a set of operations which alter the behaviour of a lua object. A metatable is just an ordinary table, which is used in a special way. local meta = { } -- create a table for use as metatable -- a metatable can change the behaviour of many things -- here we modify the 'tostrin...
Some metamethods don't have to be functions. To most important example for this is the __index metamethod. It can also be a table, which is then used as lookup. This is quite commonly used in the creation of classes in lua. Here, a table (often the metatable itself) is used to hold all the operation...
5.2 Objects in lua are garbage collected. Sometimes, you need to free some resource, want to print a message or do something else when an object is destroyed (collected). For this, you can use the __gc metamethod, which gets called with the object as argument when the object is destroyed. You could...
There are many more metamethods, some of them are arithmetic (e.g. addition, subtraction, multiplication), there are bitwise operations (and, or, xor, shift), comparison (<, >) and also basic type operations like == and # (equality and length). Lets build a class which supports many of these o...
There is a metamethod called __call, which defines the bevahiour of the object upon being used as a function, e.g. object(). This can be used to create function objects: -- create the metatable with a __call metamethod local meta = { __call = function(self) self.i = self.i + 1 e...
Perhaps the most important use of metatables is the possibility to change the indexing of tables. For this, there are two actions to consider: reading the content and writing the content of the table. Note that both actions are only triggered if the corresponding key is not present in the table. Re...
Sometimes, you don't want to trigger metamethods, but really write or read exactly the given key, without some clever functions wrapped around the access. For this, lua provides you with raw table access methods: -- first, set up a metatable that allows no read/write access local meta = { __i...
To create a background session // Swift: let mySessionID = "com.example.bgSession" let bgSessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(mySessionID) let session = NSURLSession(configuration: bgSessionConfig) // add tasks here //...
In C# 5.0 and earlier the developer could only suppress warnings by number. With the introduction of Roslyn Analyzers, C# needs a way to disable warnings issued from specific libraries. With C# 6.0 the pragma directive can suppress warnings by name. Before: #pragma warning disable 0501 C# 6.0: ...
Ionic Framework A Cross-platform mobile application development framework using Angular JS and Front End web technologies. Official website: http://ionicframework.com/ Documentation: http://ionicframework.com/docs/ Installation and Setup Installation Ionic required NPM(Node Package Manager) an...
import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; /** * A very simple Swing example. */ public class SwingExample { /** * The number of times the ...
import std.stdio; void main() { int[] arr = [1, 2, 3, 4]; writeln(arr.length); // 4 writeln(arr[2]); // 3 // type inference still works auto arr2 = [1, 2, 3, 4]; writeln(typeof(arr2).stringof); // int[] }
import std.stdio; void main() { int[] arr = [1, 2, 3]; // concatenate arr ~= 4; writeln(arr); // [1, 2, 3, 4] // per element operations arr[] += 10 writeln(arr); // [11, 12, 13, 14] }
import std.stdio; void main() { int[] arr = [1, 2, 3, 4, 5]; auto arr2 = arr[1..$ - 1]; // .. is the slice syntax, $ represents the length of the array writeln(arr2); // [2, 3, 4] arr2[0] = 42; writeln(arr[1]); // 42 }
You can create a new branch and switch to it using git checkout -b AP-57 After you use git checkout to create a new branch, you will need to set that upstream origin to push to using git push --set-upstream origin AP-57 After that, you can use git push while you are on that branch.
3D transforms can be use to create many 3D shapes. Here is a simple 3D CSS cube example: HTML: <div class="cube"> <div class="cubeFace"></div> <div class="cubeFace face2"></div> </div> CSS: body { perspective-origin: 5...

Page 304 of 1336