Tutorial by Examples: ect

Using the collect() helper, you can easily create new collection instances by passing in an array such as: $fruits = collect(['oranges', 'peaches', 'pears']); If you don't want to use helper functions, you can create a new Collection using the class directly: $fruits = new Illuminate\Support\Co...
NSURL *url = [NSURL URLWithString:@"http://www.example.com/"]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // Configure the session here. NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; [[s...
Effects can be applied to audio by chaining nodes between the source and the destination node. In this example we use a gain node to mute the source, and only let sound through at specific times. This allows us to create morse code. function morse(gainNode, pattern) { let silenceTimeout = 300; ...
Creating and returning an image object by loading the image data from the file at the specified path. Example: UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[cellCountry objectForKey:@"Country_Flag"] ofType:nil]]; Using Array: Example NSM...
Given the following definitions : public interface IMyInterface1 { string GetName(); } public interface IMyInterface2 { string GetName(); } public class MyClass : IMyInterface1, IMyInterface2 { string IMyInterface1.GetName() { return "IMyInterface1"...
Singleton Objects Scala supports static members, but not in the same manner as Java. Scala provides an alternative to this called Singleton Objects. Singleton objects are similar to a normal class, except they can not be instantiated using the new keyword. Below is a sample singleton class: object...
Array.prototype.map(): Returns a new array with the results of calling a provided function on every element in the original array. The following code example takes an array of persons and creates a new array containing persons with a 'fullName' property var personsArray = [ { id: 1, f...
begin returns an iterator to the first element in the sequence container. end returns an iterator to the first element past the end. If the vector object is const, both begin and end return a const_iterator. If you want a const_iterator to be returned even if your vector is not const, you can use ...
Collection initialization syntax can be used when instantiating any class which implements IEnumerable and has a method named Add which takes a single parameter. In previous versions, this Add method had to be an instance method on the class being initialized. In C#6, it can also be an extension me...
Initialize a UICollectionView with a CGRect frame: Swift: let collection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 200, height: 21)) Objective C: UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 200, 21)]; You can also create a UICollectionVi...
Every collection view must have a Datasource object. The Datasource object is the content that your app will display within the UICollectionView. At a minimum, all Datasource objects must implement the collectionView:numberOfItemsInSection: and collectionView:cellForItemAtIndexPath: methods. Requir...
We can create empty thread objects and assign work to them later. If we assign a thread object to another active, joinable thread, std::terminate will automatically be called before the thread is replaced. #include <thread> void foo() { std::this_thread::sleep_for(std::chrono::seco...
To obtain a Java's Class object from Kotlin's KClass use the .java extension property: val stringKClass: KClass<String> = String::class val c1: Class<String> = stringKClass.java val c2: Class<MyClass> = MyClass::class.java The latter example will be optimized by the compile...
The conventional connect syntax that uses SIGNAL and SLOT macros works entirely at runtime, which has two drawbacks: it has some runtime overhead (resulting also in binary size overhead), and there's no compile-time correctness checking. The new syntax addresses both issues. Before checking the synt...
AngularJS directives are what controls the rendering of the HTML inside an AngularJS application. They can be an Html element, attribute, class or a comment. Directives are used to manipulate the DOM, attaching new behavior to HTML elements, data binding and many more. Some of examples of directives...
public class Tag { public IList<string> Synonyms { get; set; } } Synonyms is a collection-type property. When the Tag object is created using object initializer syntax, Synonyms can also be initialized with collection initializer syntax: Tag t = new Tag { Synonyms = new List&...
Recursion is when a method calls itself. Preferably it will do so until a specific condition is met and then it will exit the method normally, returning to the point from which the method was called. If not, a stack overflow exception might occur due to too many recursive calls. /// <summary>...
To connect to a local Wildfly server via the command line, the tool bin/jboss-cli.sh can be used: $ ./bin/jboss-cli.sh --connect [standalone@localhost:9990 /] To connect to a remote Wildfly server, use the --controller option: $ ./bin/jboss-cli.sh --connect --controller=localhost:9990 [stan...
Sometimes a term is defined in multiple sections of the manual. By default, man will only display the first page it finds, which can be annoying for programmers because C functions are documented in a later section than commands and system calls. Use the following to display all pages that match a...
When you need to pass a collection into a Java method: import scala.collection.JavaConverters._ val scalaList = List(1, 2, 3) JavaLibrary.process(scalaList.asJava) If the Java code returns a Java collection, you can turn it into a Scala collection in a similar manner: import scala.collectio...

Page 22 of 99