hyTags
HomeHome DocumentationDocumentation

value-default-to

Returns the last value of the specified type, or a default value if the last value is nil.
Parameter
Type
Description
value
T?
The default value to use if the last value is nil
type
Type
The type of value to retrieve from last value
commands
Commands
Commands that return the default value to use if the last value is nil
return
T
Returns the last value if not nil, otherwise returns the default value
Test Case:Returns value when not nil
    <div></div>
    
    <string-new value="hello">
    <value-default-to value="default" type="string"></value-default-to>
    <assert-equal value="hello" type="string">
    
    👆 Try to change something!
  • Test Case:Returns default when nil
      <div></div>
      
      <value-nil type="string">
      <value-default-to value="default" type="string"></value-default-to>
      <assert-equal value="default" type="string">
      
      👆 Try to change something!
    • Test Case:Returns default from commands when nil
        <div></div>
        
        <value-nil type="string">
        <value-default-to type="string">
          <string-new value="default">
        </value-default-to>
        <assert-equal value="default" type="string">
        
        👆 Try to change something!
      • Test succeeded Test failed