Tutorial by Examples

enum MyEnum { One, Two, Three } foreach(MyEnum e in Enum.GetValues(typeof(MyEnum))) Console.WriteLine(e); This will print: One Two Three
The FlagsAttribute can be applied to an enum changing the behaviour of the ToString() to match the nature of the enum: [Flags] enum MyEnum { //None = 0, can be used but not combined in bitwise operations FlagA = 1, FlagB = 2, FlagC = 4, FlagD = 8 //you must use pow...
Running the latest Liferay CE is straightforward: Go to https://www.liferay.com/downloads. Choose a bundle among the ones listed. For beginners, the Tomcat bundle is a good choice. Click in "Download." Unzip the download package whenever you find fit. The unzipped directory will...
One of the main differences between lists and tuples in Python is that tuples are immutable, that is, one cannot add or modify items once the tuple is initialized. For example: >>> t = (1, 4, 9) >>> t[0] = 2 Traceback (most recent call last): File "<stdin>", l...
With promises: function doTheThing() { return doOneThing() .then(doAnother) .then(doSomeMore) .catch(handleErrors) } With async functions: async function doTheThing() { try { const one = await doOneThing(); const another = await doAnother(...
You can use a column's number (where the leftmost column is '1') to indicate which column to base the sort on, instead of describing the column by its name. Pro: If you think it's likely you might change column names later, doing so won't break this code. Con: This will generally reduce readabilit...
Requirements: Protractor requires the following dependencies to be installed prior to installation: Java JDK 1.7 or higher Node.js v4 or higher Installation: Download and install Node.js from this URL: https://nodejs.org/en/ To see if the Node.js installation is successfull, you can go an...
Defining position as fixed we can remove an element from the document flow and set its position relatively to the browser window. One obvious use is when we want something to be visible when we scroll to the bottom of a long page. #stickyDiv { position:fixed; top:10px; left:10px; } ...
HTML <div class="rotate"></div> CSS .rotate { width: 100px; height: 100px; background: teal; transform: rotate(45deg); } This example will rotate the div by 45 degrees clockwise. The center of rotation is in the center of the div, 50% from left and ...
HTML <div class="scale"></div> CSS .scale { width: 100px; height: 100px; background: teal; transform: scale(0.5, 1.3); } This example will scale the div to 100px * 0.5 = 50px on the X axis and to 100px * 1.3 = 130px on the Y axis. The center of the...
HTML <div class="translate"></div> CSS .translate { width: 100px; height: 100px; background: teal; transform: translate(200px, 50%); } This example will move the div by 200px on the X axis and by 100px * 50% = 50px on the Y axis. You can also spe...
HTML <div class="skew"></div> CSS .skew { width: 100px; height: 100px; background: teal; transform: skew(20deg, -30deg); } This example will skew the div by 20 degrees on the X axis and by - 30 degrees on the Y axis. The center of the transform is ...
A context manager is any object that implements two magic methods __enter__() and __exit__() (although it can implement other methods as well): class AContextManager(): def __enter__(self): print("Entered") # optionally return an object return "A-ins...
The following are data types intrinsic to Fortran: integer real character complex logical integer, real and complex are numeric types. character is a type used to store character strings. logical is used to store binary values .true. or .false.. All numeric and logical intrinsic types are...
Define a new type, mytype: type :: mytype integer :: int real :: float end type mytype Declare a variable of type mytype: type(mytype) :: foo The components of a derived type can be accessed with the % operator1: foo%int = 4 foo%float = 3.142 A Fortran 2003 feature (not yet ...
Content has been moved back to the good 'ol JSF wiki page
To raise an exception use Kernel#raise passing the exception class and/or message: raise StandardError # raises a StandardError.new raise StandardError, "An error" # raises a StandardError.new("An error") You can also simply pass an error message. In this case, the message i...
A custom exception is any class that extends Exception or a subclass of Exception. In general, you should always extend StandardError or a descendant. The Exception family are usually for virtual-machine or system errors, rescuing them can prevent a forced interruption from working as expected. # ...
Use the begin/rescue block to catch (rescue) an exception and handle it: begin # an execution that may fail rescue # something to execute in case of failure end A rescue clause is analogous to a catch block in a curly brace language like C# or Java. A bare rescue like this rescues Stand...
You can handle multiple errors in the same rescue declaration: begin # an execution that may fail rescue FirstError, SecondError => e # do something if a FirstError or SecondError occurs end You can also add multiple rescue declarations: begin # an execution that may fail rescue ...

Page 116 of 1336