pecan

States

Any coroutine instance is in one of the following states, which can be checked with the state variable:

Return value

If a coroutine terminated with a return statement, the returned value is available in the returned field. Otherwise, the field is set to null. Coroutines that return Void will have returned with a type of pecan.Void.

Example: returned usage

var adder = pecan.Co.co(function():String {
  var x = accept();
  var y = accept();
  return '$x + $y = ${x + y}';
}, (_ : Int));

var instance = adder.run();
instance.give(1);
instance.give(2);
trace(instance.returned); // output: 1 + 2 = 3
« Previous: Labels Next: API »