Skip to main content

setkey

setkey(
@llll ## llll (required)
@key ## symbol (required)
@val ## anything (required)
@mode 0
) -> llll

Sets the value of a given key in a llll. If @mode is 0 (default), values for non-existent keys are ignored. It assumes the llll consists of key-value pairs, and is wrapped at the top level, like so:

[
[ '<key1>' <value1> ]
[ '<key2>' <value2> ]
...
[ '<keyN>' <valueN> ]
]

Arguments

  • @llll [llll]: llll to modify. (required)
  • @key [symbol]: Name of llll key. (required)
  • @val [anything]: New value for llll key. (required)
  • @mode [int]: Behavior mode. (default: 0).
    • 0: Only set values for existing keys
    • 1: Always set values and create new keys when necessary.

Output

Modified llll [llll]


Usage

$point = [["x" 1.5] ["y" 0.3]];
$point = $point.setkey("x", -2); ## reassign to update
print($point) ## [["x" -2] ["y" 0.3]]