Tutorial by Examples: ant

If you want your application to support a plug-in system, for example to load plug-ins from assemblies located in plugins folder: interface IPlugin { string PluginDescription { get; } void DoWork(); } This class would be located in a separate dll class HelloPlugin : IPlugin { ...
namespace CodeContractsDemo { using System; using System.Diagnostics.Contracts; public class Point { public int X { get; set; } public int Y { get; set; } public Point() { } public Point(int x, int y) { ...
In C, character constants and string literals are different things. A character surrounded by single quotes like 'a' is a character constant. A character constant is an integer whose value is the character code that stands for the character. How to interpret character constants with multiple charac...
PHP 5.5 introduces Generators and the yield keyword, which allows us to write asynchronous code that looks more like synchronous code. The yield expression is responsible for giving control back to the calling code and providing a point of resumption at that place. One can send a value along the yi...
You can move a container instead of copying it: void print(const std::vector<int>& vec) { for (auto&& val : vec) { std::cout << val << ", "; } std::cout << std::endl; } int main() { // initialize vec1 with 1, 2, 3, 4 and...
Suppose, that we have three users : The Administrator of the database > admin The application with a full access for her data > read_write The read only access > read_only --ACCESS DB REVOKE CONNECT ON DATABASE nova FROM PUBLIC; GRANT CONNECT ON DATABASE nova TO user; With th...
To use the constant simply use its name: if (EARTH_IS_FLAT) { print "Earth is flat"; } print APP_ENV_UPPERCASE; or if you don't know the name of the constant in advance, use the constant function: // this code is equivalent to the above code $const1 = "EARTH_IS_FLAT&quo...
XML <House> <LivingRoom> <plant name="rose"/> </LivingRoom> <TerraceGarden> <plant name="passion fruit"/> <plant name="lily"/> <plant name="golden duranta"/> ...
Pi The following returns the value of PI formatted to 6 decimal places. The actual value is good to DOUBLE; SELECT PI(); -> 3.141593
You should not save props into state. It is considered an anti-pattern. For example: export default class MyComponent extends React.Component { constructor() { super(); this.state = { url: '' } this.onChange = this.onChange.bind(this); ...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
For some reasons you may want to ignore your build variants. For example: you have 'mock' product flavour and you use it only for debug purposes, such as unit/instrumentation tests. Let's ignore mockRelease variant from our project. Open build.gradle file and write: // Remove mockRelease as it...
class Lion { private double weight; // only accessible with-in class this(double weight) { this.weight = weight; } double weightInPounds() const @property // const guarantees no modifications // @property functions are treated as fields { ret...
Servant is a library for declaring APIs at the type-level and then: write servers (this part of servant can be considered a web framework), obtain client functions (in haskell), generate client functions for other programming languages, generate documentation for your web applications and m...
Inspired by PowerShell: Function doesn't have proper return value function bar { [System.Collections.ArrayList]$MyVariable = @() $MyVariable.Add("a") | Out-Null $MyVariable.Add("b") | Out-Null $MyVariable } The Out-Null is necessary because the .NET ArrayLis...
Represents an instant in time. Can be thought of as a wrapper around a Unix timestamp. Instant now = Instant.now(); Instant epoch1 = Instant.ofEpochMilli(0); Instant epoch2 = Instant.parse("1970-01-01T00:00:00Z"); java.time.temporal.ChronoUnit.MICROS.between(epoch1, epoch2); // 0
The revert command allows discarding unwanted uncommitted changes. Reverting changes to a single file. hg revert example.c Reverting all changes. This will discard all changes not just the current directory. hg revert --all hg will output which files were reverted. reverting exa...
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...
A Semantic Model offers a deeper level of interpretation and insight of code compare to a syntax tree. Where syntax trees can tell the names of variables, semantic models also give the type and all references. Syntax trees notice method calls, but semantic models give references to the precise locat...
The value of a type hole can simply said to be undefined, although a typed hole triggers a compile-time error, so it is not strictly necessary to assign it a value. However, a typed hole (when they are enabled) produces a compile time error (or warning with deferred type errors) which states the nam...

Page 7 of 11