Thunk<A>
class
class Thunk<A> {
A _cached;
Function gen;
Thunk(A gen()) : this.gen = gen;
A get value {
if (_cached == null) {
_cached = gen();
}
return _cached;
}
}
Constructors
new Thunk(A gen()) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful
through their identity. An Object instance is equal to itself
only.
Thunk(A gen()) : this.gen = gen;
Properties
final A value #
A get value {
if (_cached == null) {
_cached = gen();
}
return _cached;
}