Whitespace is handled by the lexical analyzer before being parsed.
The lexical analyzer uses a stack to store indentation levels. At the beginning, the stack contains just the value 0, which is the leftmost position. Whenever a nested block begins, the new indentation level is pushed on the stack, ...
Creating a custom directive with isolated scope will separate the scope inside the directive from the outside scope, in order to prevent our directive from accidentally change the data in the parent scope and restricting it from reading private data from the parent scope.
To create an isolated scop...
Python has several functions built into the interpreter.
If you want to get information of keywords, built-in functions, modules or topics open a Python console and enter:
>>> help()
You will receive information by entering keywords directly:
>>> help(help)
or within the u...
Mongoose populate is used to show data for referenced documents from other collections.
Lets say we have a Person model that has referenced documents called Address.
Person Model
var Person = mongoose.model('Person', {
fname: String,
mname: String,
lname: String,
address: {typ...
Racket functions can also have keyword arguments, which are specified with a keyword followed by the argument expression. A keyword begins with the characters #:, so a keyword argument looks like #:keyword arg-expr. Within a function call this looks like (function #:keyword arg-expr).
> (define ...
If you want to create and send signals in your own code (for example, if you are writing an extension), create a new Signal instance and call send when the subscribers should be notified. Signals are created using a Namespace.
from flask import current_app
from flask.signals import Namespace
n...
This example shows a minimal Mockito test using a mocked ArrayList:
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRu...
Components are simply instances that implement the Ashley component class.
import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.ComponentMapper;
public class Position implements Component {
public static final ComponentMapper<Position> Map =
...
Entity systems are how you perform functional operations on sets of entities. Components should typically not have logic associated with them that involves awareness of data or state of other component instances, as that is the job of an entity system. An entity system can not be registered to mor...
Closures are inline anonymous methods that have the ability to use Parent method variables and other anonymous methods which are defined in the parent's scope.
In essence, a closure is a block of code which can be executed at a
later time, but which maintains the environment in which it was firs...
The IEnumerable<T> interface has a single method, GetEnumerator(), which returns an IEnumerator<T>.
While the yield keyword can be used to directly create an IEnumerable<T>, it can also be used in exactly the same way to create an IEnumerator<T>. The only thing that changes ...
Some languages include a list data structure. Common Lisp, and other languages in the Lisp family, make extensive use of lists (and the name Lisp is based on the idea of a LISt Processor). However, Common Lisp doesn't actually include a primitive list datatype. Instead, lists exist by convention....
A cons cell, also known as a dotted pair (because of its printed representation), is simply a pair of two objects. A cons cell is created by the function cons, and elements in the pair are extracted using the functions car and cdr.
(cons "a" 4)
For instance, this returns a pair whose ...
Following is most basic expression tree that is created by lambda.
Expression<Func<int, bool>> lambda = num => num == 42;
To create expression trees 'by hand', one should use Expression class.
Expression above would be equivalent to:
ParameterExpression parameter = Expression.Pa...
This will create a timer to call the doSomething method on self in 5 seconds.
Swift
let timer = NSTimer.scheduledTimerWithTimeInterval(5,
target: self,
selector: Selector(doSomething()),
userInfo: nil,
...
Swift
timer.fire()
Objective-C
[timer fire];
Calling the fire method causes an NSTimer to perform the task it would have usually performed on a schedule.
In a non-repeating timer, this will automatically invalidate the timer. That is, calling fire before the time interval is up will result ...
Swift
timer.invalidate()
Objective-C
[timer invalidate];
This will stop the timer from firing. Must be called from the thread the timer was created in, see Apple's notes:
You must send this message from the thread on which the timer was installed. If you send this message from another thr...