Closure class

A Closure takes a Function argument that returns a Status. The function is executed by a call to the update() method of the Closure.

The main use case of the Closure type is to avoid having to explicitly write/subclass a Node type and/or to capture the surrounding scope at declaration.

Example:

void closureExample() {
  var x = 0;

  final closure = Closure(() {
    // capture x from local scope and compute a Status
    return ++x % 2 == 0 ? Status.success : Status.failure;
  });

  assert(closure.update() == Status.failure);
  assert(closure.update() == Status.success);
  assert(closure.update() == Status.failure);
}
Inheritance

Constructors

Closure(Status _closure())
Construct a Closure with the specified Function argument.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
inherited
toString() String
A string representation of this object.
inherited
update() Status
override

Operators

operator ==(Object other) bool
The equality operator.
inherited