Tutorial by Examples

The Premain class will contain the method "premain(String agentArgs Instrumentation inst)" Here is an example: import java.lang.instrument.Instrumentation; public class PremainExample { public static void premain(String agentArgs, Instrumentation inst) { System.out.print...
fn main() { let english = "Hello, World!"; println!("{}", &english[0..5]); // Prints "Hello" println!("{}", &english[7..]); // Prints "World!" } Note that we need to use the & operator here. It takes a reference and ...
A very useful feature of Swift 2.2 is having the ability of extending protocols. It works pretty much like abstract classes when regarding a functionality you want to be available in all the classes that implements some protocol (without having to inherit from a base common class). protocol FooPro...
// This example creates a macro `set!` that functions similarly to the built-in // macro vec! use std::collections::HashSet; macro_rules! set { ( $( $x:expr ),* ) => { // Match zero or more comma delimited items { let mut temp_set = HashSet::new(); // Create a ...
If you are running Docker on OS X or Windows, docker-compose should be included in your Docker for Windows or Docker Toolbox installation. On Linux you can get the latest binaries straight from the GitHub release page: https://github.com/docker/compose/releases You can install the specific releas...
Flexbox is a layout mode providing for the arrangement of elements on a page such that the elements behave predictably when the page layout must accommodate different screen sizes and different display devices. By default flexbox arranges children in a column. But you can change it to row using flex...
Improper use of pointers are frequently a source of bugs that can include security bugs or program crashes, most often due to segmentation faults. Not checking for allocation failures Memory allocation is not guaranteed to succeed, and may instead return a NULL pointer. Using the returned value, w...
let list1 = [ 1; 2 ] let list2 = [ 1 .. 100 ] // Accessing an element printfn "%A" list1.[0] // Pattern matching let rec patternMatch aList = match aList with | [] -> printfn "This is an empty list" | head::tail -> printfn "This list consists o...
Create a .gitattributes file in the project root containing: * -text This is equivalent to setting core.autocrlf = false.
Create a .gitattributes file in the project root containing: * text=auto This will result in all text files (as identified by Git) being committed with LF, but checked out according to the host operating system default. This is equivalent to the recommended core.autocrlf defaults of: input o...
__construct() is the most common magic method in PHP, because it is used to set up a class when it is initialized. The opposite of the __construct() method is the __destruct() method. This method is called when there are no more references to an object that you created or when you force its deletion...
When contributors add to a project from different machines or operating systems, it may happen that they use different email addresses or names for this, which will fragment contributor lists and statistics. Running git shortlog -sn to get a list of contributors and the number of commits by them co...
Props are used to transfer data from parent to child component. Props are read only. Child component can only get the props passed from parent using this.props.keyName. Using props one can make his component reusable.
Once setup is completed. Copy the code below to index.android.js or to index.ios.js file to use the props. import React, { Component } from 'react'; import { AppRegistry, Text, View } from 'react-native'; class Greeting extends Component { render() { return ( <Text>Hello {t...
Whenever an object is treated as a string, the __toString() method is called. This method should return a string representation of the class. class User { public $first_name; public $last_name; public $age; public function __toString() { return "{$this->first_...
This example is showing how to query a database with database/sql, taking as example a MySql database. package main import ( "log" "fmt" "database/sql" _ "github.com/go-sql-driver/mysql" ) func main() { dsn := "mysql_usern...
Generally speaking, empty commits (or commits with state that is identical to the parent) is an error. However, when testing build hooks, CI systems, and other systems that trigger off a commit, it's handy to be able to easily create commits without having to edit/touch a dummy file. The --allow-e...
It's a very common extension that allows type classes with multiple type parameters. You can think of MPTC as a relation between types. {-# LANGUAGE MultiParamTypeClasses #-} class Convertable a b where convert :: a -> b instance Convertable Int Float where convert i = fromIntegr...
Regular instances require: All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type variables*, and each type variable appears at most once in the instance head. That means that, for example, while you can create an instance for [a] you can't create an instance f...
Normally, string literals in Haskell have a type of String (which is a type alias for [Char]). While this isn't a problem for smaller, educational programs, real-world applications often require more efficient storage such as Text or ByteString. OverloadedStrings simply changes the type of literals...

Page 157 of 1336