Tutorial by Examples: er

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...
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 ...
with other sets # Intersection {1, 2, 3, 4, 5}.intersection({3, 4, 5, 6}) # {3, 4, 5} {1, 2, 3, 4, 5} & {3, 4, 5, 6} # {3, 4, 5} # Union {1, 2, 3, 4, 5}.union({3, 4, 5, 6}) # {1, 2, 3, 4, 5, 6} {1, 2, 3, 4, 5} | {3, 4, 5, 6} # {1, 2, 3, 4, 5, 6} # Difference ...
Often we want to operate only on elements of an array that fulfill a specific condition: Select Will return elements that match a specific condition array = [1, 2, 3, 4, 5, 6] array.select { |number| number > 3 } # => [4, 5, 6] Reject Will return elements that do not match a specific c...
Introduction SharePoint 2016 is the version 16 release of the SharePoint product family. It was released on May 4, 2016. This example covers the installation of SharePoint 2016 using the Single Server Farm configuration. This configuration covers the basics of setting up a SharePoint farm without t...
CommandDescription<Esc>Leaves insert mode, triggers autocommands and abbreviations<C-[>Exact synonymous of <Esc><C-c>Leaves insert mode, doesn't trigger autocommands Some people like to use a relatively uncommon pair of characters like jk as shortcut for <Esc> or <C...
Active patterns are a special type of pattern matching where you can specify named categories that your data may fall into, and then use those categories in match statements. To define an active pattern that classifies numbers as positive, negative or zero: let (|Positive|Negative|Zero|) num = ...
If the items in your RecyclerView load data from the network (commonly images) or carry out other processing, that can take a significant amount of time and you may end up with items on-screen but not fully loaded. To avoid this you can extend the existing LinearLayoutManager to preload a number of...
SharedPreferences sharedPreferences = ...; sharedPreferences.registerOnSharedPreferenceChangeListener(mOnSharedPreferenceChangeListener); private final SharedPreferences.OnSharedPreferenceChangeListener mOnSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener(...
Govendor is a tool that is used to import 3rd party packages into your code repository in a way that is compatible with golang's vendoring. Say for example that you are using a 3rd party package bosun.org/slog: package main import "bosun.org/slog" func main() { slog.Infof(&quo...
NSAttributedString (and its mutable sibling NSMutableAttributedString) allows you to create strings that are complex in their appearance to the user. A common application is to use this to display a string and adding custom kerning / letter-spacing. This would be achieved as follows (where label ...
Method overloading, also known as function overloading, is the ability of a class to have multiple methods with the same name, granted that they differ in either number or type of arguments. Compiler checks method signature for method overloading. Method signature consists of three things - Met...
Method overriding is the ability of subtypes to redefine (override) the behavior of their supertypes. In Java, this translates to subclasses overriding the methods defined in the super class. In Java, all non-primitive variables are actually references, which are akin to pointers to the location of...
Objective-C CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.x"]; animation.fromValue = @0; animation.toValue = @320; animation.duration = 1; [_label.layer addAnimation:animation forKey:@"basic"]; Swift let animation = CAB...
Often, we need to perform an operation over every element in a variadic template parameter pack. There are many ways to do this, and the solutions get easier to read and write with C++17. Suppose we simply want to print every element in a pack. The simplest solution is to recurse: C++11 void print...
The internal keyword makes a class (including nested classes), property, method or field available to every consumer in the same assembly: internal class Foo { internal string SomeProperty {get; set;} } internal class Bar { var myInstance = new Foo(); internal string SomeField ...
docker run --restart=always -d <container> By default, Docker will not restart containers when the Docker daemon restarts, for example after a host system reboot. Docker provides a restart policy for your containers by supplying the --restart command line option. Supplying --restart=always ...
traverse_ executes an Applicative action for every element in a Foldable structure. It ignores the action's result, keeping only the side-effects. (For a version which doesn't discard results, use Traversable.) -- using the Writer applicative functor (and the Sum monoid) ghci> runWriter $ trave...
The ternary operator is used for inline conditional expressions. It is best used in simple, concise operations that are easily read. The order of the arguments is different from many other languages (such as C, Ruby, Java, etc.), which may lead to bugs when people unfamiliar with Python's "s...
JavaScript will try to automatically convert variables to more appropriate types upon use. It's usually advised to do conversions explicitly (see other examples), but it's still worth knowing what conversions take place implicitly. "1" + 5 === "15" // 5 got converted to string. ...

Page 40 of 417