Let's extend our template from above and include content from header.php and footer.php
Including header:
We will include header right after Template name comment
There are two common ways to do this. Both are right and work same, it's just about your style and how code looks
First way:
<?ph...
We will further extend our template and include title of the page and a content
<?php
/*
Template Name: Example
*/
get_header();
the_title();
the_content();
get_footer();
And if you want you can wrap them with HTML elements like this
<?php
/*
Template Name: Example
*...
If we have a struct like this
struct Box {
let name: String
let thingsInside: Int
}
and an array of Box(es)
let boxes = [
Box(name: "Box 0", thingsInside: 1),
Box(name: "Box 1", thingsInside: 2),
Box(name: "Box 2", thingsInside: 3),
B...
Download Heroku Toolbelt.
Navigate to the root of the sources of your Django app. You'll need tk
Type heroku create [app_name]. If you don't give an app name, Heroku will randomly generate one for you. Your app URL will be http://[app name].herokuapp.com
Make a text file with the ...
Values can be given names using let:
# let a = 1;;
val a : int = 1
You can use similar syntax to define a function. Just provide additional parameters for the arguments.
# let add arg1 arg2 = arg1 + arg2;;
val add : int -> int -> int = <fun>
We can call it like this:
# add 1...
The function keyword automatically has pattern matching when you define the
body of your function. Observe it below:
# let foo = function
0 -> "zero"
| 1 -> "one"
| 2 -> "couple"
| 3 -> "few"
| _ -> "many";;
val foo : int ->...
3.0
let string = "My fantastic string"
var index = string.startIndex
while index != string.endIndex {
print(string[index])
index = index.successor()
}
Note: endIndex is after the end of the string (i.e. string[string.endIndex] is an error, but string[string.startIndex] i...
[1, 2, [[3, 4], [5]], 6].flatten # => [1, 2, 3, 4, 5, 6]
If you have a multi-dimensional array and you need to make it a simple (i.e. one-dimensional) array, you can use the #flatten method.
Standard enumerations allow users to declare a useful name for a set of integers. The names are collectively referred to as enumerators. An enumeration and its associated enumerators are defined as follows:
enum myEnum
{
enumName1,
enumName2,
};
An enumeration is a type, one which is...
A common use for enumerators is for switch statements and so they commonly appear in state machines. In fact a useful feature of switch statements with enumerations is that if no default statement is included for the switch, and not all values of the enum have been utilized, the compiler will issue ...
If targeting Flash Player 11+, the built-in removeChildren method is the best way to remove all children:
removeChildren(); //a start and end index can be passed
For legacy applications, the same can be accomplished with a loop:
while (numChildren > 0) {
removeChildAt(0);
}
Enums in Swift are much more powerful than some of their counterparts in other languages, such as C. They share many features with classes and structs, such as defining initialisers, computed properties, instance methods, protocol conformances and extensions.
protocol ChangesDirection {
mutati...
package {
import flash.events.TimerEvent;
import flash.utils.Timer;
public class CountdownTimer extends Timer {
public var time:Number = 0;
public function CountdownTimer(time:Number = Number.NEGATIVE_INFINITY, delay:Number = 1000) {
super(delay, repeatCount);
...
Using functions that take in and execute closures can be extremely useful for sending a block of code to be executed elsewhere. We can start by allowing our function to take in an optional closure that will (in this case) return Void.
func closedFunc(block: (()->Void)? = nil) {
print("...
Note:
Everything below applies to the str.format method, as well as the
format function. In the text below, the two are interchangeable.
For every value which is passed to the format function, Python looks for a __format__ method for that argument. Your own custom class can therefore have th...
// RawRepresentable has an associatedType RawValue.
// For this struct, we will make the compiler infer the type
// by implementing the rawValue variable with a type of String
//
// Compiler infers RawValue = String without needing typealias
//
struct NotificationName: RawRepresentable {
...
A protocol may specify that only a class can implement it through using the class keyword in its inheritance list. This keyword must appear before any other inherited protocols in this list.
protocol ClassOnlyProtocol: class, SomeOtherProtocol {
// Protocol requirements
}
If a non-class typ...
3.0
Swift 3 introduces the CountedSet class (it's the Swift version of the NSCountedSet Objective-C class).
CountedSet, as suggested by the name, keeps track of how many times a value is present.
let countedSet = CountedSet()
countedSet.add(1)
countedSet.add(1)
countedSet.add(1)
countedSet.a...
Select the .xcdatamodeld file. You will notice you have no
entities. You will have to create one yourself. At the bottom of
Xcode you will notice a button that says "Add Entity" click it and
you will have a new entity for you to work with on the project.
In this step there are ...