Yielding Return Values
In Coco, endpoints use named return values, which you can set either with yield or by simple assignment. While yield
and assignment are essentially the same and set the return values anywhere in the code, return
can be used to explicitly set the return value and exit the endpoint. Endpoints with no outputs may do nothing using pass
.
coco Yielding
endpoint SenderIdentifier() -> (addr Identifier):
// assignment can be used instead of yield
yield addr Identifier(Sender)
addr = Identifier(Sender) // same as above
endpoint MapCheck(a []U64, m Map[U64]String) -> (has Bool):
for elem in a:
if !m[elem]?:
return (has: false)
has = true
endpoint DoNothing():
pass