Tutorial by Examples: er

Good error handling prevents end users from seeing VBA runtime errors and helps the developer easily diagnose and correct errors. There are three main methods of Error Handling in VBA, two of which should be avoided for distributed programs unless specifically required in the code. On Error GoTo 0...
When filtering a value that should be an integer filter_var() will return the filtered data, in this case the integer, or false if the value is not an integer. Floats are not integers: var_dump(filter_var('10', FILTER_VALIDATE_INT)); var_dump(filter_var('a10', FILTER_VALIDATE_INT)); var_dump(filt...
When validating that an integer falls in a range the check includes the minimum and maximum bounds: $options = array( 'options' => array( 'min_range' => 5, 'max_range' => 10, ) ); var_dump(filter_var('5', FILTER_VALIDATE_INT, $options)); var_dump(filter_var('...
C++11 We can combine the principles of the Rule of Five and RAII to get a much leaner interface: the Rule of Zero: any resource that needs to be managed should be in its own type. That type would have to follow the Rule of Five, but all users of that resource do not need to write any of the five sp...
A std::regex_token_iterator provides a tremendous tool for extracting elements of a Comma Separated Value file. Aside from the advantages of iteration, this iterator is also able to capture escaped commas where other methods struggle: const auto input = "please split,this,csv, ,line,\\,\n&quot...
When processing of captures has to be done iteratively a regex_iterator is a good choice. Dereferencing a regex_iterator returns a match_result. This is great for conditional captures or captures which have interdependence. Let's say that we want to tokenize some C++ code. Given: enum TOKENS { ...
Generators are useful when you need to generate a large collection to later iterate over. They're a simpler alternative to creating a class that implements an Iterator, which is often overkill. For example, consider the below function. function randomNumbers(int $length) { $array = []; ...
Our randomNumbers() function can be re-written to use a generator. <?php function randomNumbers(int $length) { for ($i = 0; $i < $length; $i++) { // yield tells the PHP interpreter that this value // should be the one used in the current iteration. yield mt...
One common use case for generators is reading a file from disk and iterating over its contents. Below is a class that allows you to iterate over a CSV file. The memory usage for this script is very predictable, and will not fluctuate depending on the size of the CSV file. <?php class CsvReade...
The AppCompat Support Library defines several useful styles for Buttons, each of which extend a base Widget.AppCompat.Button style that is applied to all buttons by default if you are using an AppCompat theme. This style helps ensure that all buttons look the same by default following the Material D...
There are only two string operators: Concatenation of two strings (dot): $a = "a"; $b = "b"; $c = $a . $b; // $c => "ab" Concatenating assignment (dot=): $a = "a"; $a .= "b"; // $a => "ab"
The order in which operators are evaluated is determined by the operator precedence (see also the Remarks section). In $a = 2 * 3 + 4; $a gets a value of 10 because 2 * 3 is evaluated first (multiplication has a higher precedence than addition) yielding a sub-result of 6 + 4, which equals to 10...
Filter code: angular.module('myModule', []).filter('multiplier', function() { return function(number, multiplier) { if (!angular.isNumber(number)) { throw new Error(number + " is not a number!"); } if (!multiplier) { multiplier = 2; } return numbe...
Implementing IErrorHandler for WCF services is a great way to centralize error handling and logging. The implementation shown here should catch any unhandled exception that is thrown as a result of a call to one of your WCF services. Also shown in this example is how to return a custom object, and h...
CanRunApplication To check to see if the user has permission to run the given application. If not, AccessDeniedException is thrown. Assert.CanRunApplication("WebEdit"); HasAccess HasAccess will check if the given parameter is true, otherwise an AccessDeniedException will be thrown. ...
When writing a class with generics in java, it is possible to ensure that the type parameter is an enum. Since all enums extend the Enum class, the following syntax may be used. public class Holder<T extends Enum<T>> { public final T value; public Holder(T init) { t...
This query returns all cones with a chocolate scoop and a vanilla scoop. VANILLA, CHOCOLATE, MINT, STRAWBERRY = 1, 2, 3, 4 # constants for flavors choco_vanilla_cones = IceCream.objects.filter(scoops__contains=[CHOCOLATE, VANILLA]) Don't forget to import the IceCream model from your models.py ...
This query returns all cones with either a mint scoop or a vanilla scoop. minty_vanilla_cones = IceCream.objects.filter(scoops__contained_by=[MINT, VANILLA])
Create a Loader object: var loader:Loader = new Loader(); //import Add listeners on the loader. Standard ones are complete and io/security errors loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); //when the loader is done loading, call this function loader.co...
The browser function can be used like a breakpoint: code execution will pause at the point it is called. Then user can then inspect variable values, execute arbitrary R code and step through the code line by line. Once browser() is hit in the code the interactive interpreter will start. Any R code ...

Page 65 of 417