Tutorial by Examples

import React, { Component } from 'react'; type Props = { posts: Array<Article>, dispatch: Function, children: ReactElement } class Posts extends Component { props: Props; render () { // rest of the code goes here } }
The reference to the outer class uses the class name and this public class OuterClass { public class InnerClass { public void method() { System.out.println("I can access my enclosing class: " + OuterClass.this); } } } You can access fields and ...
Elements of String are characters that can be accessed by the indexing operation string[index]. val str = "Hello, World!" println(str[1]) // Prints e String elements can be iterated with a for-loop. for (c in str) { println(c) }
Kotlin has two types of string literals: Escaped string Raw string Escaped string handles special characters by escaping them. Escaping is done with a backslash. The following escape sequences are supported: \t, \b, \n, \r, \', \", \\ and \$. To encode any other character, use the Unicod...
Both escaped strings and raw strings can contain template expressions. Template expression is a piece of code which is evaluated and its result is concatenated into string. It starts with a dollar sign $ and consists of either a variable name: val i = 10 val s = "i = $i" // evaluates to ...
In Kotlin strings are compared with == operator which chect for their structural equality. val str1 = "Hello, World!" val str2 = "Hello," + " World!" println(str1 == str2) // Prints true Referential equality is checked with === operator. val str1 = ""&q...
Download Play! 1. Goto http://www.playframework.com/download and download latest Play! release (play-2.5.X.zip at the time of this writing). Unzip in a directory of your choice. We’ll refer to uncompressed folder directory as PLAY_HOME. Add PLAY_HOME folder to you PATH environment variable, so that...
You can make your plugin customizable by accepting options. $.fn.colourize = function(options) { // This is one method to support default options var style = $.extend({ color: "green", backgroundColor: "white" }, options); // Set the col...
While writing jQuery plugins is simple, we want to enclose our plugins in a local scope. This will avoid namespace conflicts as well as polluting the global namespace, on top of ensuring that jQuery is loaded before our plugin extends it. // Encapsulate our plugins in a local scope (function($) { ...
//create a new ExcelPackage using (ExcelPackage excelPackage = new ExcelPackage()) { //create a WorkSheet ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1"); //fill cell data with a loop, note that row and column indexes start at 1 Random rnd...
//create a new ExcelPackage using (ExcelPackage excelPackage = new ExcelPackage()) { //create a WorkSheet ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1"); //fill cell data with a loop, note that row and column indexes start at 1 Random rnd...
The async package provides functions for asynchronous code. Using the auto function you can define asynchronous relations between two or more functions: var async = require('async'); async.auto({ get_data: function(callback) { console.log('in get_data'); // async code to ...
You can delete trailing spaces with the following command. :%s/\s\+$//e This command is explained as follows: enter Command mode with : do this to the entire file with % (default would be for the current line) substitute action s / start of the search pattern \s whitespace character \+ e...
You can delete all blank lines in a file with the following command: :g/^$/d This command is explained as follows: enter Command mode with : g is a global command that should occur on the entire file / start of the search pattern the search pattern of blank line is ^g /end of the search pat...
You can convert tabs to spaces by doing the following: First check that expandtab is switched off :set noexpandtab Then :retab! which replaces spaces of a certain length with tabs If you enable expandtab again :set expandtab then and run the :retab! command then all the tabs becomes spaces...
import WatchConnectivity var watchSession : WCSession? override func awake(withContext context: Any?) { super.awake(withContext: context) // Configure interface objects here. startWatchSession() } func startWatchSession(){ if(WCSession....
Boolean literals are the simplest of the literals in the Java programming language. The two possible boolean values are represented by the literals true and false. These are case-sensitive. For example: boolean flag = true; // using the 'true' literal flag = false; // using the 'fa...
func isValidEmail(email: String) -> Bool { let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx) return emailTest.evaluate(with: email) } or you could use String extensio...
//create a list to hold all the values List<string> excelData = new List<string>(); //read the Excel file as byte array byte[] bin = File.ReadAllBytes("C:\\ExcelDemo.xlsx"); //or if you use asp.net, get the relative path byte[] bin = File.ReadAllBytes(Server.MapPath(&q...
Let's say that you have the following class: public class PersonInfo { public int ID { get; set; } [Display(Name = "First Name")] [Required(ErrorMessage = "Please enter your first name!")] public string FirstName{ get; set; } [Display(Name = "L...

Page 1069 of 1336