Tutorial by Examples

Imagine you have all dates in all responses in some custom format, for instance /Date(1465935152)/ and you want apply general rule to deserialize all Json dates to java Date instances. In this case you need to implement custom Json Deserializer. Example of json: { "id": 1, "cr...
Of the LINQ methods which use deferred execution, some require a single value to be evaluated at a time. The following code: var lst = new List<int>() {3, 5, 1, 2}; var streamingQuery = lst.Select(x => { Console.WriteLine(x); return x; }); foreach (var i in streamingQuery) { ...
Let's take a sample class. class Book: def __init__(self, title, author): self.title = title self.author = author book1 = Book(title="Right Ho, Jeeves", author="P.G. Wodehouse") In Python you can access the attribute title of the class using the dot ...
For the sake of data encapsulation, sometimes you want to have an attribute which value comes from other attributes or, in general, which value shall be computed at the moment. The standard way to deal with this situation is to create a method, called getter or a setter. class Book: def __init...
It is possible to use IO.inspect/1 as a tool to debug an elixir program. defmodule MyModule do def myfunction(argument_1, argument_2) do IO.inspect(argument_1) IO.inspect(argument_2) end end It will print out argument_1 and argument_2 to the console. Since IO.inspect/1 returns i...
ChoiceDialog allows the user to pick one item from a list of options. List<String> options = new ArrayList<>(); options.add("42"); options.add("9"); options.add("467829"); options.add("Other"); ChoiceDialog<String> dialog = new Choice...
PDO is a universal database connection command in PHP, it support 12 different database type e.g MySQL, MongoDB, NoSQL. A big bonus about PDO is that it calculate your code to support the database type, so you don't need to make any chance when moving over to another database system. Summary PDO...
When a function doesn't preserve units automatically due to lower-level operations, the LanguagePrimitives module can be used to set units on the primitives that support them: /// This cast preserves units, while changing the underlying type let inline castDoubleToSingle (x : float<'u>) : fl...
The [<Measure>] attribute can be used on type parameters to declare types that are generic with respect to units of measure: type CylinderSize<[<Measure>] 'u> = { Radius : float<'u> Height : float<'u> } Test usage: open Microsoft.FSharp.Data.UnitSystems...
For example, types for SI units have been standardized in the F# core library, in Microsoft.FSharp.Data.UnitSystems.SI. Open the appropriate sub-namespace, UnitNames or UnitSymbols, to use them. Or, if only a few SI units are required, they can be imported with type aliases: /// Seconds, the SI uni...
the spaceship operator returns -1 when the left operator is smaller, 0 when the operators are equal and 1 otherwise: assert 10 <=> 20 == -1 assert 10 <=> 10 ​== 0 assert 30 <=> 10 == 1 assert 'a' <=> 'b' == -1 assert 'a' <=> 'a'​== 0 assert 'b' <=> 'a' == ...
class User { String name int age } def users = [ new User(name: "Bob", age: 20), new User(name: "Tom", age: 50), new User(name: "Bill", age: 45) ] // sort by age users.sort { a, b -> a.age <=> b.age }
If you don't have permissions to install perl modules, you may still install them manually, indicating a custom path where you've got writing permissions. Fist, download and unzip module archive: wget module.tar.gz tar -xzf module.tar.gz cd module Then, if the module distribution contains a M...
All values in Rust have exactly one owner. The owner is responsible for dropping that value when it goes out of scope, and is the only one who may move the ownership of the value. The owner of a value may give away references to it by letting other pieces of code borrow that value. At any given time...
All values in Rust have a lifetime. A value's lifetime spans the segment of code from the value is introduced to where it is moved, or the end of the containing scope { let x = String::from("hello"); // + // ... : let y = S...
Most of the questions around ownership come up when writing functions. When you specify the types of a function's arguments, you may choose how that value is passed in. If you only need read-only access, you can take an immutable reference: fn foo(x: &String) { // foo is only authorized to...
Some Rust types implement the Copy trait. Types that are Copy can be moved without owning the value in question. This is because the contents of the value can simply be copied byte-for-byte in memory to produce a new, identical value. Most primitives in Rust (bool, usize, f64, etc.) are Copy. let x...
After Successfully installing Xamarin Studio on OS X. It's time for the first Hello World Application. Hello World Application: Xamarin.Forms What is Xamarin Forms : Xamarin.Forms is a new library that enables you to build native UIs for iOS, Android and Windows Phone from a single, shared C# c...
def pow = { base, exponent -> base ** exponent } assert pow(3, 2) == 9 def pow2 = pow.curry(2) //base == 2 assert pow2(3) == 8
def dividable = { a, b -> a % b == 0 } assert dividable(2, 3) == false assert dividable(4, 2) == true def even = dividable.rcurry(2) // b == 2 assert even(2) == true assert even(3) == false

Page 592 of 1336