Tutorial by Examples: cs

If the type on which the static constructor is declared is generic, the static constructor will be called once for each unique combination of generic arguments. class Animal<T> { static Animal() { Console.WriteLine(typeof(T).FullName); } public static void Yawn...
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...
Assertions are used not to perform testing of input parameters, but to verify that program flow is corect -- i.e., that you can make certain assumptions about your code at a certain point in time. In other words: a test done with Debug.Assert should always assume that the value tested is true. Debu...
This example goes over how to set up CoreNLP from the GitHub repo. The GitHub code has newer features than the official release, but may be unstable. This example will take you through downloading, building, and running a simple command-line invocation of CoreNLP. Prerequisites: Java 8 or newer....
There are three basic rules of semicolon insertion: When, as the program is parsed from left to right, a token (called the offending token) is encountered that is not allowed by any production of the grammar, then a semicolon is automatically inserted before the offending token if one or more o...
empty statement var statement expression statement do-while statement continue statement break statement return statement throw statement Examples: When the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream as a single complete Pro...
<style> input:in-range { border: 1px solid blue; } </style> <input type="number" min="10" max="20" value="15"> <p>The border for this value will be blue</p> The :in-range CSS pseudo-class matches when an element...
Variadic functions are created using the ... ellipses syntax in the argument list of the function definition. function id(...) return end If you called this function as id(1, 2, 3, 4, 5) then ... (AKA the vararg list) would contain the values 1, 2, 3, 4, 5. Functions can take required arg...
The easiest and quickest way to encode a Haskell data type to JSON with Aeson is using generics. {-# LANGUAGE DeriveGeneric #-} import GHC.Generics import Data.Text import Data.Aeson import Data.ByteString.Lazy First let us create a data type Person: data Person = Person { firstName :...
GSP supports the usage of <% %> scriptlet blocks to embed Groovy code (this is discouraged): <html> <body> <% out << "Hello GSP!" %> </body> </html> You can also use the <%= %> syntax to output values, like in JSP: <htm...
The complete sample code for this application (Android + Node server) is available in the PayPal Developer Github repository. At this point the PayPal future payments button has been clicked, we have an auth code and metadata ID from the PayPal SDK, and we need to pass those on to our server to com...
Review Partial Application before proceeding. In Haskell, a function that can take other functions as arguments or return functions is called a higher-order function. The following are all higher-order functions: map :: (a -> b) -> [a] -> [b] filter :: (a -> Bool) -> [a] ...
SELECT @@VERSION Returns the version of MS SQL Server running on the instance. SELECT @@SERVERNAME Returns the name of the MS SQL Server instance. SELECT @@SERVICENAME Returns the name of the Windows service MS SQL Server is running as. SELECT serverproperty('ComputerNamePhysicalNetBIOS'...
If everything whas been set up correctly, the following snippet will show a window titled "SFML works!" with a green circle: #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!"); sf::CircleShape shape(100.f...
Structures can be made generic over one or more type parameters. These types are given enclosed in <> when referring to the type: struct Gen<T> { x: T, z: isize, } // ... let _: Gen<bool> = Gen{x: true, z: 1}; let _: Gen<isize> = Gen{x: 42, z: 2}; let _: Gen...
Select all columns from some table (system table in this case): SELECT * FROM sys.objects Or, select just some specific columns: SELECT object_id, name, type, create_date FROM sys.objects
In Groovy, the inject() method is one of the cumulative methods that allows us to add (or inject) new functionality into any object that implements the inject() method. In the case of a Collection, we can apply a closure to a collection of objects uniformly and then collate the results into a single...
Angular also provides some CSS classes for forms and inputs depending on their state ClassDescriptionng-touchedField has been touchedng-untouchedField has not been touchedng-pristineField has not been modifiedng-dirtyField has been modifiedng-validField is validng-invalidField is invalid You can u...
void main() { import std.algorithm : group; import std.range; [1, 2].chain([3, 4]).retro; // [4, 3, 2, 1] [1, 1, 2, 2, 2].group.dropOne.front; // tuple(2, 3u) }

Page 11 of 24