hyTags
HomeHome DocumentationDocumentation

object-update

Updates an object property by passing its current value to commands and storing the result.
Parameter
Type
Description
self
Object
The object containing the property to update
key
String
The key of the property to update
type
Type
The type of the property value
commands
Commands
Commands to execute with the current value as initial stack value
return
void
No return value.
Test Case:Increment a number property
    <div></div>
    
    <object-new>
    <object-set key="count">
      <number-new value="10">
    </object-set>
    <object-update key="count" type="number">
      <number-add value="5">
    </object-update>
    <object-get key="count" type="number">
    <assert-equal value="15" type="number">
    
    👆 Try to change something!
  • Test Case:Append to a string property
      <div></div>
      
      <object-new>
      <object-set key="text">
        <string-new value="hello">
      </object-set>
      <object-update key="text" type="string">
        <string-append string=" world">
      </object-update>
      <object-get key="text" type="string">
      <assert-equal value="hello world" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed