Tutorial by Examples: c

There are two possible ways to pass a value type by reference: ref and out. The difference is that by passing it with ref the value must be initialized but not when passing it with out. Using out ensures that the variable has a value after the method call: public void ByRef(ref int value) { C...
It is not possible to directly use static_cast, const_cast, dynamic_cast and reinterpret_cast on std::shared_ptr to retrieve a pointer sharing ownership with the pointer being passed as argument. Instead, the functions std::static_pointer_cast, std::const_pointer_cast, std::dynamic_pointer_cast and ...
curl -XGET http://www.example.com:9200/myIndexName/_search?pretty=true&q=*:* This uses the Search API and will return all the entries under index myIndexName. Reference Link: Here
Suppose we have a json : { "total_count": 132, "page_size": 2, "page_index": 1, "twitter_posts": [ { "created_on": 1465935152, "tweet_id": 210462857140252672, "tweet": "Along with our ne...
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...
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 ...
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...
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 }
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...
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
def quatNorm = { a, b, c, d -> Math.sqrt(a*a + b*b + c*c + d*d) } assert quatNorm(1, 4, 4, -4) == 7.0 def complexNorm = quatNorm.ncurry(1, 0, 0) // b, c == 0 assert complexNorm(3, 4) == 5.0
def noParam = { "I have $it" } def noParamCurry = noParam.curry(2) assert noParamCurry() == 'I have 2'
def honestlyNoParam = { -> "I Don't have it" } // The following all throw IllegalArgumentException honestlyNoParam.curry('whatever') honestlyNoParam.rcurry('whatever') honestlyNoParam.ncurry(0, 'whatever')
Because generating documentation is based on markdown, you have to do 2 things : 1/ Write your doctest and make your doctest examples clear to improve readability (It is better to give a headline, like "examples" or "tests"). When you write your tests, do not forget to give 4 s...
Once you've installed the .NET CLI tools, you can create a new project with the following command: dotnet new --lang f# This creates a command line program.

Page 368 of 826