Tutorial by Examples: is

.NET Framework defines a interface for types requiring a tear-down method: public interface IDisposable { void Dispose(); } Dispose() is primarily used for cleaning up resources, like unmanaged references. However, it can also be useful to force the disposing of other resources even though ...
First, import the libraries that work with files: from os import listdir from os.path import isfile, join, exists A helper function to read only files from a directory: def get_files(path): for file in listdir(path): full_path = join(path, file) if isfile(full_path): ...
// *** Find all the objects which is of type movie, Both the syntax are valid *** NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",@1]; // OR //NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",[NSNumbe...
// *** Find Distinct object ids of array *** NSLog(@"Distinct id : %@",[array valueForKeyPath:@"@distinctUnionOfObjects.id"]);
// *** Case Insensitive comparison with exact title match *** NSPredicate *filterByNameCIS = [NSPredicate predicateWithFormat:@"self.title LIKE[cd] %@",@"Tom and Jerry"]; NSLog(@"Filter By Name(CIS) : %@",[array filteredArrayUsingPredicate:filterByNameCIS]);
// *** Case Insensitive comparison with matching subset *** NSPredicate *filterByName = [NSPredicate predicateWithFormat:@"self.title CONTAINS[cd] %@",@"Tom"]; NSLog(@"Filter By Containing Name : %@",[array filteredArrayUsingPredicate:filterByName]);
There are times in which it is desirable to consolidate factor levels into fewer groups, perhaps because of sparse data in one of the categories. It may also occur when you have varying spellings or capitalization of the category names. Consider as an example the factor set.seed(1) colorful <...
NSString *pathToPlist = [[NSBundle mainBundle] pathForResource:@"plistName" ofType:@"plist"]; NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:pathToPlist];
public bool IsTypeNullable<T>() { return Nullable.GetUnderlyingType( typeof(T) )!=null; }
A common usage scenario that this feature really helps with is when you are looking for an object in a collection and need to create a new one if it does not already exist. IEnumerable<MyClass> myList = GetMyList(); var item = myList.SingleOrDefault(x => x.Id == 2) ?? new MyClass { Id = 2...
The simplest way to concatenate list1 and list2: merged = list1 + list2 zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables: alist = ['a1', 'a2', 'a3'] blist = ['b1', 'b2', 'b3'] for a, b in zip(alist, blist):...
Bitwise operators can be used to perform bit level operation on variables. Below is a list of all six bitwise operators supported in C: SymbolOperator&bitwise AND|bitwise inclusive OR^bitwise exclusive OR (XOR)~bitwise not (one's complement)<<logical left shift>>logical right shift...
Let's suppose we have a reference to the JQuery type definition and we want to extend it to have additional functions from a plugin we included and which doesn't have an official type definition. We can easily extend it by declaring functions added by plugin in a separate interface declaration with ...
Python has only limited support for parsing ISO 8601 timestamps. For strptime you need to know exactly what format it is in. As a complication the stringification of a datetime is an ISO 8601 timestamp, with space as a separator and 6 digit fraction: str(datetime.datetime(2016, 7, 22, 9, 25, 59, 55...
Given a JList like JList myList = new JList(items); the selected items in the list can be modified through the ListSelectionModel of the JList: ListSelectionModel sm = myList.getSelectionModel(); sm.clearSelection(); // clears the selection sm.setSelectionInterval(inde...
This example adds a list of places with image and name by using an ArrayList of custom Place objects as dataset. Activity layout The layout of the activity / fragment or where the RecyclerView is used only has to contain the RecyclerView. There is no ScrollView or a specific layout needed. <?x...
package { import flash.events.EventDispatcher; public class AbstractDispatcher extends EventDispatcher { public function AbstractDispatcher(target:IEventDispatcher = null) { super(target); } } } To dispatch an event on an instance: var dispatcher:AbstractDispatcher =...
dolist is a looping macro created to easily loop through the lists. One of the simplest uses would be: CL-USER> (dolist (item '(a b c d)) (print item)) A B C D NIL ; returned value is NIL Note that since we did not provide return value, NIL is returned (and A,B,C,D are ...
List doesn't support "random access", which means it takes more work to get, say, the fifth element from the list than the first element, and as a result there's no List.get nth list function. One has to go all the way from the beginning (1 -> 2 -> 3 -> 4 -> 5). If you need ra...
Draw samples from a normal (gaussian) distribution # Generate 5 random numbers from a standard normal distribution # (mean = 0, standard deviation = 1) np.random.randn(5) # Out: array([-0.84423086, 0.70564081, -0.39878617, -0.82719653, -0.4157447 ]) # This result can also be achieved with t...

Page 20 of 109