Tutorial by Examples: f

This example is about deliberately ignoring or "squashing" exceptions. Or to be more precise, it is about how to catch and handle an exception in a way that ignores it. However, before we describe how to do this, we should first point out that squashing exceptions is generally not the co...
This exception occurs when a collection is modified while iterating over it using methods other than those provided by the iterator object. For example, we have a list of hats and we want to remove all those that have ear flaps: List<IHat> hats = new ArrayList<>(); hats.add(new Ushanka...
For Each row As DataRow In FooDataTable.Rows Me.RowsToProcess.Add(row) Next Dim myOptions As ParallelOptions = New ParallelOptions() myOptions.MaxDegreeOfParallelism = environment.processorcount Parallel.ForEach(RowsToProcess, myOptions, Sub(currentRow, state) ...
In C++, a byte is the space occupied by a char object. The number of bits in a byte is given by CHAR_BIT, which is defined in climits and required to be at least 8. While most modern systems have 8-bit bytes, and POSIX requires CHAR_BIT to be exactly 8, there are some systems where CHAR_BIT is great...
There are two possible ways to pass a value type by reference: ref and out. The difference is that by passing it with ref the value must be initialized but not when passing it with out. Using out ensures that the variable has a value after the method call: public void ByRef(ref int value) { C...
The tree command lists the contents of a specified directory in a tree-like format. If no directory is specified then, by default, the contents of the current directory are listed. Example Output: $ tree /tmp /tmp ├── 5037 ├── adb.log └── evince-20965    └── image.FPWTJY.png Use the tree ...
The [<Measure>] attribute can be used on type parameters to declare types that are generic with respect to units of measure: type CylinderSize<[<Measure>] 'u> = { Radius : float<'u> Height : float<'u> } Test usage: open Microsoft.FSharp.Data.UnitSystems...
class User { String name int age } def users = [ new User(name: "Bob", age: 20), new User(name: "Tom", age: 50), new User(name: "Bill", age: 45) ] // sort by age users.sort { a, b -> a.age <=> b.age }
All values in Rust have a lifetime. A value's lifetime spans the segment of code from the value is introduced to where it is moved, or the end of the containing scope { let x = String::from("hello"); // + // ... : let y = S...
Most of the questions around ownership come up when writing functions. When you specify the types of a function's arguments, you may choose how that value is passed in. If you only need read-only access, you can take an immutable reference: fn foo(x: &String) { // foo is only authorized to...
After Successfully installing Xamarin Studio on OS X. It's time for the first Hello World Application. Hello World Application: Xamarin.Forms What is Xamarin Forms : Xamarin.Forms is a new library that enables you to build native UIs for iOS, Android and Windows Phone from a single, shared C# c...
def pow = { base, exponent -> base ** exponent } assert pow(3, 2) == 9 def pow2 = pow.curry(2) //base == 2 assert pow2(3) == 8
To find active ScriptableObjects during runtime, you can use Resources.FindObjectsOfTypeAll(). T[] instances = Resources.FindObjectsOfTypeAll<T>(); Where T is the type of the ScriptableObject instance you're searching. Active means it has been loaded in memory in some form before. This me...
A shallow copy is a copy of a collection without performing a copy of its elements. >>> import copy >>> c = [[1,2]] >>> d = copy.copy(c) >>> c is d False >>> c[0] is d[0] True
If you have nested lists, it is desireable to clone the nested lists as well. This action is called deep copy. >>> import copy >>> c = [[1,2]] >>> d = copy.deepcopy(c) >>> c is d False >>> c[0] is d[0] False
You can create shallow copies of lists using slices. >>> l1 = [1,2,3] >>> l2 = l1[:] # Perform the shallow copy. >>> l2 [1,2,3] >>> l1 is l2 False
I create a file called database-servlet.xml somewhere on the classpath. Initially your config file will look like this: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/...
One of the great things about Linq is that it is so easy to extend. You just need to create an extension method whose argument is IEnumerable<T>. public namespace MyNamespace { public static class LinqExtensions { public static IEnumerable<List<T>> Batch<T&...
One of the easiest examples of using shared services is when we want to store some data from a given page of our application, and then get that data again but from another page. One option could be to send that data as a parameter (for instance, if one page calls the other one) but if we want to us...
The following sqoop command will be used to import the data from RDBMS table into HBase table, if the table does not exists in HBase it will create a new table and import the data into this table sqoop import \ --query 'select emp_id, emp_name, emp_sal from employee where $CONDITIONS' \ ...

Page 197 of 457