hyTags
HomeHome DocumentationDocumentation

closure-execute

Executes a closure with the current runtime context.
Parameter
Type
Description
self
AnyClosure
The closure to execute
change-selection
Bool?
Whether to use the current frame's selection instead of the parent's selection
return
T
Result of the closure execution
Test Case:Execute closure with computation
    <function name="compute" params="block: () -> number" return="number">
      <var-get name="block">
      <closure-execute></closure-execute>
    </function>
    
    <function-call name="compute" block>
      <number-new value="5">
      <number-multiply value="3">
    </function-call>
    <assert-equal value="15" type="number">
    
    👆 Try to change something!
  • Test Case:Execute closure with string manipulation
      <function name="transform" params="block: () -> string" return="string">
        <var-get name="block">
        <closure-execute></closure-execute>
      </function>
      
      <function-call name="transform" block>
        <string-new value="hello">
        <string-uppercase>
      </function-call>
      <assert-equal value="HELLO" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed