P2Block

Acts as a closure encompassing PonderTalk statements. Any variables used by the statements within the block are untouched once the block is created. Blocks may have arguments that are handed in when they are executed. When a block is executed it returns returns the value of the last statement executed within the block. c.f. function calls.

Factory Messages
OperationDescription

Operational Messages
OperationReturnDescription
onError: anErrorBlock P2Object associates anErrorBlock with the receiver. The error block is executed if a Ponder2 error occurs in the receiver. The error block is given one P2Error argument which contains the error details.
values: anArray P2Object Executes the block with anArray of arguments. Answers with the result of the last statement executed by the block.
hasArgs: aHash P2Object Returns true if aHash contains entries that match all the names of the arguments that the block requires. Otherwise returns false.
value P2Object executes the block with no arguments. Answers with the result of the last statement executed by the block.
value: arg0 P2Object Executes the block with one argument: arg0. Answers with the result of the last statement executed by the block.
value: arg0 value: arg1 P2Object Executes the block with two arguments: arg0 and arg1. Answers with the result of the last statement executed by the block.
value: arg0 value: arg1 value: arg2 P2Object Executes the block with three arguments: arg0, arg1 and arg2. Answers with the result of the last statement executed by the block.
valueHash: aHash P2Object The block is executed with the values of its arguments being taken by name from aHash. Answers the value of the last statement executed by the block. Throws an error if aHash does not satisfy the block's arguments.
whileFalse: aBlock self While the receiver is false, keep executing aBlock with no arguments
whileTrue: aBlock self While the receiver is true, keep executing aBlock with no arguments