Tutorial by Examples

Once registered a dependency can be retrieved by adding parameters on the Controller constructor. // ... using System; using Microsoft.Extensions.DependencyInjection; namespace Core.Controllers { public class HomeController : Controller { public HomeController(ITestServic...
Named functions function multiply(a, b) { return a * b; } Anonymous functions let multiply = function(a, b) { return a * b; }; Lambda / arrow functions let multiply = (a, b) => { return a * b; };
It's possible to create a new ASP.NET Core project entirely from the command line using the dotnet command. dotnet new web dotnet restore dotnet run dotnet new web scaffolds a new "empty" web project. The web parameter tells the dotnet tool to use the ASP.NET Core Empty template. Use...
Records are an extension of sum algebraic data type that allow fields to be named: data StandardType = StandardType String Int Bool --standard way to create a sum type data RecordType = RecordType { -- the same sum type with record syntax aString :: String , aNumber :: Int , isTrue :...
With C++11 and higher calculations at compile time can be much easier. For example calculating the power of a given number at compile time will be following: template <typename T> constexpr T calculatePower(T value, unsigned power) { return power == 0 ? 1 : value * calculatePower(value,...
Access ModifierVisibilityInheritancePrivateClass onlyCan't be inheritedNo modifier / PackageIn packageAvailable if subclass in packageProtectedIn packageAvailable in subclassPublicEverywhereAvailable in subclass There was once a private protected (both keywords at once) modifier that could be appli...
Haskell is a pure language, meaning that expressions cannot have side effects. A side effect is anything that the expression or function does other than produce a value, for example, modify a global counter or print to standard output. In Haskell, side-effectful computations (specifically, those wh...
Here is how to make a Heads Up Notification for capable devices, and use a Ticker for older devices. // Tapping the Notification will open up MainActivity Intent i = new Intent(this, MainActivity.class); // an action to use later // defined as an app constant: // public static final String ME...
Using Razor @functions keyword gives the capability of introducing classes and methods for inline use within a Razor file: @functions { string GetCssClass(Status status) { switch (status) { case Status.Success: return "alert-success&qu...
App::uses('YourModel', 'Model'); $model_1 = new YourModel(array('ds' => 'default')); $model_2 = new YourModel(array('ds' => 'database2'));
We can use partial application to "lock" the first argument. After applying one argument we are left with a function which expects one more argument before returning the result. (+) :: Int -> Int -> Int addOne :: Int -> Int addOne = (+) 1 We can then use addOne in order to...
Returning partially applied functions is one technique to write concise code. add :: Int -> Int -> Int add x = (+x) add 5 2 In this example (+x) is a partially applied function. Notice that the second parameter to the add function does not need to be specified in the function definitio...
Consider the character class [aeiou]. This character class can be used in a regular expression to match a set of similarly spelled words. b[aeiou]t matches: bat bet bit bot but It does not match: bout btt bt Character classes on their own match one and only one character at a time...
For Addition "4" + 2 # Gives "42" 4 + "2" # Gives 6 1,2,3 + "Hello" # Gives 1,2,3,"Hello" "Hello" + 1,2,3 # Gives "Hello1 2 3" For Multiplication "3" * 2 # Gives "33" 2 * "3&quot...
If a type wishes to have value semantics, and it needs to store objects that are dynamically allocated, then on copy operations, the type will need to allocate new copies of those objects. It must also do this for copy assignment. This kind of copying is called a "deep copy". It effective...
A type has value semantics if the object's observable state is functionally distinct from all other objects of that type. This means that if you copy an object, you have a new object, and modifications of the new object will not be in any way visible from the old object. Most basic C++ types have v...
A class can have members. Instance variables can be declared with/without type annotations, and optionally initialized. Uninitialised members have the value of null, unless set to another value by the constructor. class Foo { var member1; int member2; String member3 = "Hello world!&q...
Swift let viewController = UIViewController() Objective-C UIViewController *viewController = [UIViewController new];
To access pixel values in an OpenCV cv::Mat object, you first have to know the type of your matrix. The most common types are: CV_8UC1 for 8-bit 1-channel grayscale images; CV_32FC1 for 32-bit floating point 1-channel grayscale images; CV_8UC3 for 8-bit 3-channel color images; and CV_32FC3 ...
Setup monitoring beacons func initiateRegion(ref:BeaconHandler){ let uuid: NSUUID = NSUUID(UUIDString: "<UUID>") let beacon = CLBeaconRegion(proximityUUID: uuid, identifier: "") locationManager?.requestAlwaysAuthorization() //cllocation manager obj. ...

Page 240 of 1336