hyTags
HomeHome DocumentationDocumentation

closure-new

Creates a new closure with the specified commands.
Parameter
Type
Description
commands
Commands
The commands to execute when the closure is called
return
anyClosure
New closure
Test Case:Create and execute closure returning string
    <function name="runClosure" params="block: () -> string" return="string">
      <var-get name="block">
      <closure-execute></closure-execute>
    </function>
    
    <function-call name="runClosure" block>
      <string-new value="from closure">
    </function-call>
    <assert-equal value="from closure" type="string">
    
    👆 Try to change something!
  • Test Case:Create and execute closure returning number
      <function name="runClosure" params="block: () -> number" return="number">
        <var-get name="block">
        <closure-execute></closure-execute>
      </function>
      
      <function-call name="runClosure" block>
        <number-new value="100">
      </function-call>
      <assert-equal value="100" type="number">
      
      👆 Try to change something!
    • Test succeeded Test failed